// This program Calculates your BMI
import java.util.Scanner; // Scanner is in the java.util package
public class BmiCalculator
{
public static void main(String[] args)
{
// create a Scanner object to receive input value
Scanner input = new Scanner(System.in);
// Ask user for weight and display the input value
System.out.println("What is your Weight in pounds");
double weight = input.nextInt();
// Ask user for height and display the input value
System.out.println("What is your Height in inches");
double height = input.nextInt();
// Calculate BMI
double bmi = (weight / (height * height)) * 703;
//Display Results
System.out.println("Your BMI is:" + bmi);
// Message to user
System.out.println("A BMI between 20 and 24 is considered ideal.");
System.out.println("Enter your goal BMI");
// set and get the goal bmi from user
double goalbmi = input.nextInt();
// calculate the new weight
double weight1 = ( (height * height) * (goalbmi/703));
//Display Results for goal weight
System.out.println("Your weight needs to be:" + weight1);
}
}
No comments:
Post a Comment