Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 10 of 10

Thread: Help with Assignment Please

  1. #1
    Junior Member
    Join Date
    Apr 2013
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help with Assignment Please

    I have this assignment and I am lost on it. I think I have it written but it continuosly gives an error cannot find symbol on (Checkup check). I am lost and in desperate need of help.

    Here is my assignment:
    Create a class named TestCheckup whose main() method declares four Checkup objects. Call a getData() method four times. Within the method, prompt a user for values for each field for a Checkup, and return a Checkup object to the main() method where it is assigned to one of main()’s Checkup objects. Then, in main(), pass each Checkup object in turn to a showValues() method that displays the data. Blood pressure values are usually displayed with a slash between the systolic and diastolic numbers. (Typical blood pressure values are 110/78 or 130/90.) With the cholesterol figures, display the explanation of the cholesterol ratio calculation. (Typical cholesterol values are 100 and 40 or 180 and 70.) The comment header provided in Unit 1 should be added and completed. Save the Assignment as TestCheckup.java and take a screenshot of each of the following: the newly written code, the code after it is compiled, and the output of the code.

    Here is the code:
    import java.util.Scanner;
     
    public class TestCheckup
    { //begin class
     
     
     
       public static void main(String[] args)
       {
           //Create four checkup objects
           Checkup check1 = new Checkup();
           Checkup check2 = new Checkup();
           Checkup check3 = new Checkup();
           Checkup check4 = new Checkup();
     
           //Pass Checkup objects to getData method 
           getData(check1);
           getData(check2);
           getData(check3);
           getData(check4);
     
           //Pass Checkup objects to showValues() method
           showValues(check1);
           showValues(check2);
           showValues(check3);
           showValues(check4);
       }
     
    	public static Checkup getData(Checkup check)
    	{
        //Create scanner object
        Scanner keyboard = new Scanner(System.in);
     
        //Prompt user for field data values and return values
        System.out.println("Please enter stylostic pressure: " );
         check.stylostic = keyboard.nextInt();
     
       System.out.println("Please enter diastolic pressure: ");
        check.diastolic = keyboard.nextInt();
     
        System.out.println("Please enter hdl: ");
        check.hdl = keyboard.nextInt();
     
        System.out.println("Plese enter ldl: ");
        check.ldl = keyboard.nextInt();
     
        return check;
    	}
    	public static void showValues(Checkup checker)
    	{
     
     
        System.out.println("Your blood pressure is " + checker.diastolic + "/" + checker.stylostic);
     
        System.out.println("Your cholesterol is " + checker.hdl + " and " + checker.ldl);
     
        System.out.println("Typical cholestoral is 100 and 40 or 180 and 70");
     
     
     
     	}
    }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,647
    Thanks
    45
    Thanked 1,959 Times in 1,933 Posts

    Default Re: Help with Assignment Please

    Please edit your post and wrap your code with code tags:
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.

    What happens when you compile and execute the code?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Apr 2013
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help with Assignment Please

    TestCheckup.java:29: error: cannot find symbol
    public static void getData(Checkup check)
    ^
    symbol: class Checkup
    location: class TestCheckup

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,647
    Thanks
    45
    Thanked 1,959 Times in 1,933 Posts

    Default Re: Help with Assignment Please

    Where is the definition for the Checkup class? The compiler can not find a definition for it.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Apr 2013
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help with Assignment Please

    I am very new to this. How would I go about adding the check up class?

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,647
    Thanks
    45
    Thanked 1,959 Times in 1,933 Posts

    Default Re: Help with Assignment Please

    First you need to decide what the purpose of the Checkup class is. What is it supposed to do?
    Why does the current class need it?
    Then define the class, what variables it needs to hold its data and what methods it needs to do its task.
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Apr 2013
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help with Assignment Please

    Ultimately what am I going to have to do to get this program to compile?

    --- Update ---

    I declared a class Checkup and added to the TestCheckup class and it gave the following errror on compiling:

    TestCheckup.java:63: error: class Checkup is public, should be declared in a file named Checkup.java
    public class Checkup
    ^
    1 error

    ----jGRASP wedge2: exit code for process is 1.

    How do I need to declare it?

    --- Update ---

    well here it is:
    public class Checkup 
    { //begin class
     
        //Declare data fields
        int stylostic;
        int diastolic;
        int ldl;
        int hdl;
     
     
        //Create method to compute ratio
        public void computeRatio(int ld, int hd)
        {
            double ratio = ld/hd;
            System.out.println("Your ratio is: " + ratio);
     
            //Call ratio method
            explainRatio();
        }
     
        //Create method to explain circumstances
        public void explainRatio()
        {
            System.out.println("HDL is good cholesterol.");
            System.out.println("A ratio of 3.5 or lower is considered optimal.");
        }
     
    }//end class

    I just put it in at the end of the TestCheckup class after the TestCheckup }
    Is that right?

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,647
    Thanks
    45
    Thanked 1,959 Times in 1,933 Posts

    Default Re: Help with Assignment Please

    error: class Checkup is public, should be declared in a file named Checkup.java
    Since that class is defined as public, put the code in a file named: Checkup.java
    For public classes, the filename = classname
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Junior Member
    Join Date
    Apr 2013
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Help with Assignment Please

    Ok....How do I declare it in the TestCHeckup.java class? What does the code look like?

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,647
    Thanks
    45
    Thanked 1,959 Times in 1,933 Posts

    Default Re: Help with Assignment Please

    How do I declare it in the TestCHeckup.java class?
    Not sure what you are asking to declare. If the Checkup.java file compiles and creates a Checkup.class file you should be able to compile the TestCHeckup program. The compiler should find the class definition for the Checkup class if they are in the same folder.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. need help with an assignment
    By milham123 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 23rd, 2013, 03:14 PM
  2. Help with assignment
    By kayc1912 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 21st, 2013, 01:02 PM
  3. assignment troubles polymorphism (guide for assignment included)
    By tdawg422 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 8th, 2011, 10:01 AM
  4. Can someone help with my Assignment
    By damustk in forum Object Oriented Programming
    Replies: 1
    Last Post: March 14th, 2011, 03:32 PM
  5. Replies: 1
    Last Post: February 22nd, 2010, 07:20 AM