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

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

1. ## 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. ## 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.

3. ## 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. ## Re: Completely clueless as to how to do this assignment.

Originally Posted by Disruption
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.

5. ## 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. ## 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.

7. ## 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. ## 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.

9. ## Re: Completely clueless as to how to do this assignment.

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

10. ## 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.

11. ## Re: Completely clueless as to how to do this assignment.

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

12. ## 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.

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

phlegm (November 10th, 2013)

14. ## 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. ## 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.

16. ## 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. ## Re: Completely clueless as to how to do this assignment.

Originally Posted by Junky
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.