First,
Hello eveyone and I am new to Java.
I am trying to create a Java program that will calculate a person BMI based on user input of weight (in pounds) and heigh (in inches) and then display what the BMI is and give the a message that tells them where they fit plus I want to then be able to tell them how much weight they need to loss (or gain if underweight) to attain a normal BMI (25).
I have got it all to work except then last part (calculating how much they need to gain or loss to obtain a 25 BMI).
Here is the code I have so far:
Expand|Select|Wrap|Line Numbers
- import java.util.Scanner;
- import java.lang.Math;
- public class Hw05{
- public static void main (String args[]) {
- Scanner myScanner= new Scanner (System.in);
- System.out.print( "Enter your weight (in pounds): " );
- int weight= myScanner.nextInt();
- System.out.print( "Enter your height (in inches): " );
- int height = myScanner.nextInt();
- double BMI = 704.5 * weight/(height*height);
- System.out.println("Your Body Max Index = " + Math.round(BMI*100)/100);
- double ideal = 704.5 * 100/(height*height);
- if (BMI >= 39.5) {
- System.out.println("You are Severely Obese");
- System.out.println("You should try to lose " + Math.round(ideal*100)/100);
- } else if (BMI >= 29.5) {
- System.out.println("You are Obese");
- System.out.println("You should try to lose " + Math.round(ideal*100)/100);
- } else if (BMI >= 24.9) {
- System.out.println("You are Overweight");
- System.out.println("You should try to lose " + Math.round(ideal*100)/100);
- } else if (BMI <= 19.5) {
- System.out.println("You are Underweight");
- System.out.println("You should try to gain " + Math.round(ideal*100)/100);
- } else {
- System.out.println("You are Normal");
- System.out.println("You are maintaining a healthy weight!");
- }
- }
- }
PLEASE HELP
Mel
--------------------------------------------------------------------------------