# Completely clueless as to how to do this assignment.

• November 10th, 2013, 09:35 PM
Disruption
Completely clueless as to how to do this assignment.
Hey everyone,

So here is the assignment that was given to me:
Attachment 2460

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
• November 10th, 2013, 09:38 PM
Junky
Re: Completely clueless as to how to do this assignment.
One step at a time. Surely you can do
Code :

`//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.
• November 10th, 2013, 09:41 PM
Disruption
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 ");             } }  ```
• November 10th, 2013, 09:43 PM
Junky
Re: Completely clueless as to how to do this assignment.
Quote:

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.
• November 10th, 2013, 09:44 PM
Disruption
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.
• November 10th, 2013, 09:46 PM
Junky
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.
• November 10th, 2013, 09:53 PM
Disruption
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"?
• November 10th, 2013, 09:55 PM
Junky
Re: Completely clueless as to how to do this assignment.
Code :

`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.
• November 10th, 2013, 10:51 PM
Disruption
Re: Completely clueless as to how to do this assignment.
Would you mind giving me a hint in regards to this?
• November 10th, 2013, 10:57 PM
Junky
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.
• November 10th, 2013, 10:59 PM
Disruption
Re: Completely clueless as to how to do this assignment.
Attachment 2461

That's the error and I'm not understanding.
• November 10th, 2013, 11:17 PM
Junky
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.
• November 10th, 2013, 11:22 PM
Disruption
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?
• November 10th, 2013, 11:32 PM
Junky
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.
• November 11th, 2013, 06:43 AM
rodiongork
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.
• November 11th, 2013, 09:39 AM
Disruption
Re: Completely clueless as to how to do this assignment.
Quote:

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.