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 16 of 16

Thread: Completely clueless as to how to do this assignment.

  1. #1
    Junior Member
    Join Date
    Nov 2013
    Posts
    9
    My Mood
    Torn
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Completely clueless as to how to do this assignment.

    Hey everyone,

    So here is the assignment that was given to me:
    2d060e66f10d1c03c7a7c9e030b55057.jpg

    The assignment is based off of using the if statements and I'm just not familiar with how to start this. The following is how to calculate heart rate and such: Training Heart Rate using the Karvonen Formula

    The sample "guide" they showed me if I needed a reference was this:
    PHP Code:
    /**
     * Description for 4.03 Target Zone project
     * 
     * @author (Your Name)
     * @version (The Date)
     */
    import java.util.Scanner;
    public class 
    TargetZone
    {
        public static 
    void main(String[] args)
        {
            
    //Initialize and declare variables
            
    String target "within";
            
    Scanner in = new Scanner(System.in);
            
            
    //Prompt user for input
            
            
            //Calculate heart rate target zone min and max
            
            
            //Determine if heart rate after exercise is between the min and max
            
            //If the heart rate is below, change the value of target to "below".
           
           
           //If the heart rate is above, change the value of target to "above".
            
            
            //Print two output statements
            //The first stating the heart rate target zone
            
            
            //The second stating if the heart rate after exercise  was within, above or below
            //the target zone. The variable "target" will have a value of within, above or below
            
             
        
    //end main
    }//end class TargetZone 

    How do I even do this assignment?

    Thanks,
    Disruption


  2. #2
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Completely clueless as to how to do this assignment.

    One step at a time. Surely you can do
    //Prompt user for input
    When you have compile and run the code to make sure it works. If it does move onto the next step.
    Improving the world one idiot at a time!

  3. #3
    Junior Member
    Join Date
    Nov 2013
    Posts
    9
    My Mood
    Torn
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Completely clueless as to how to do this assignment.

    Hi Junky,

    Here is what I have so far:
    PHP Code:
    import java.util.Scanner;
    public class 
    TargetZone
    {
       public static 
    void main(String [] args)
       {
           
    Scanner in = new Scanner(System.in);
           
    int age;
            
           
           
    //User input
           
    System.out.println("Determine your target Heart Rate Zone for Cardiovascular Excercise (50% - 85%");
           
    System.out.println();
           
    System.out.println("Enter your age: ");
           
    age in.nextInt(); 
           
           
    //Heart Rate Target Zone Min and Max
           
    String mhr;
           
    mhr = (220 age );
           
    System.out.println("Maximum Heart Rate:" age " bmp ");
           
        }


  4. #4
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Completely clueless as to how to do this assignment.

    Quote Originally Posted by Disruption View Post
    Here is what I have so far:
    Do you have a specific question? If you are getting errors then copy and paste them here.

    BTW do not expect people to follow links to find information. Especially when it is a tiny unreadable image. You should post as much information as need for us to help you.
    Improving the world one idiot at a time!

  5. #5
    Junior Member
    Join Date
    Nov 2013
    Posts
    9
    My Mood
    Torn
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Completely clueless as to how to do this assignment.

    String mhr;
    mhr = (220 - age );
    System.out.println("Maximum Heart Rate:" + age + " bmp ")

    I am having troubles parsing the string so I can use it in the equation to determine that string mhr.

  6. #6
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Completely clueless as to how to do this assignment.

    Still not a question.

    I hate to harp on about this but it is basic communication skills that you will need to develop and use throughout your life.
    Improving the world one idiot at a time!

  7. #7
    Junior Member
    Join Date
    Nov 2013
    Posts
    9
    My Mood
    Torn
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Completely clueless as to how to do this assignment.

    I'll try it this way. I'm trying to convert an integer (int age) into a way of usage into the equation listed above (mhr = 220 - age). Upon doing that, it gives me errors such as incompatible types. How can I use the age into my string "mhr"?

  8. #8
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Completely clueless as to how to do this assignment.

    mhr = (220 - age );

    In post 4 I ask you to post any error messages you get. Surely that line gives you an error. Surely you can work out why.
    Improving the world one idiot at a time!

  9. #9
    Junior Member
    Join Date
    Nov 2013
    Posts
    9
    My Mood
    Torn
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Completely clueless as to how to do this assignment.

    Would you mind giving me a hint in regards to this?

  10. #10
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Completely clueless as to how to do this assignment.

    Would you mind posting the error. That is three times I have asked now. If you really want my help you are not going about it the right way.
    Improving the world one idiot at a time!

  11. #11
    Junior Member
    Join Date
    Nov 2013
    Posts
    9
    My Mood
    Torn
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Completely clueless as to how to do this assignment.

    32ad0099f0502610f412ab0ba2d32364.jpg

    That's the error and I'm not understanding.

  12. #12
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Completely clueless as to how to do this assignment.

    I also advised you against posting links to unreadable images. You can compile your code on the command line or your IDE should have a window called "Console" or similar that will display the full error message. That is what you need to copy and paste on the forum to get help.

    However, the partial message says Incompatible types. What type is age? What type will the result of (220 - age) be? What type is mhr? Answer those questions and the solution should be obvious.
    Improving the world one idiot at a time!

  13. The Following User Says Thank You to Junky For This Useful Post:

    phlegm (November 10th, 2013)

  14. #13
    Junior Member
    Join Date
    Nov 2013
    Posts
    9
    My Mood
    Torn
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Completely clueless as to how to do this assignment.

    Age is an Int and the result of (220 - age) should result in an int.

    MHR is a string.

    So wouldn't that mean that I am trying to get an end result of an integer?

  15. #14
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Completely clueless as to how to do this assignment.

    I have no idea what you are trying to do but you certainly cannot assign an int value to a String variable. Either mhr should be an int or you need to convert the result of (220 - age) to a String representation. Search the API to help you.
    Improving the world one idiot at a time!

  16. #15
    Member
    Join Date
    Oct 2013
    Location
    Saint-Petersburg, Russia
    Posts
    33
    Thanks
    0
    Thanked 5 Times in 5 Posts

    Default Re: Completely clueless as to how to do this assignment.

    I dare say you'll do yourself and others much good if you simply take some decent book (like Horstmann's "Core Java 2") and try to learn basics of Java - you'll need only first part of the book. The way you are trying - to learn by experiments - is painful enough... Even with people of such great patience like Junky.

    I know that you perhaps want your assignment to be done instead of being told to read some stupid book. But if you have any reason to learn - you'll need it, please believe.

  17. #16
    Junior Member
    Join Date
    Nov 2013
    Posts
    9
    My Mood
    Torn
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Completely clueless as to how to do this assignment.

    Quote Originally Posted by Junky View Post
    I have no idea what you are trying to do but you certainly cannot assign an int value to a String variable. Either mhr should be an int or you need to convert the result of (220 - age) to a String representation. Search the API to help you.
    Placing MHR as an Int solved this. Thank you for your help Junky.

Similar Threads

  1. Clueless on classes
    By antnas in forum Object Oriented Programming
    Replies: 2
    Last Post: December 2nd, 2012, 12:30 AM
  2. How to implement GregoraianCalendar which is subclass of Calender?
    By Meirikai in forum Object Oriented Programming
    Replies: 4
    Last Post: October 30th, 2012, 03:15 PM
  3. Clueless on request.getContextPath()
    By ram.java in forum What's Wrong With My Code?
    Replies: 0
    Last Post: August 29th, 2011, 12:07 PM
  4. [SOLVED] First assignment, clueless student, involving coordinates and distances
    By Kerrigan in forum Java Theory & Questions
    Replies: 7
    Last Post: March 10th, 2011, 03:52 PM
  5. Completely New to Java
    By slimshadie in forum Java Theory & Questions
    Replies: 7
    Last Post: September 6th, 2009, 01:55 PM