Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class BMI {
- public static void main(String [] args) {
- Scanner input = new Scanner (System.in);
- System.out.print("Enter your weight (kg): ");
- double weight = input.nextDouble();
- System.out.print("Enter your height (m): ");
- double height = input.nextDouble();
- double bmi = weight/(height*height);
- double low_normal = 18.5 * (height*height);
- double high_normal = 25 * (height*height);
- String result = "A";
- double gainlose = 0;
- if (bmi < 15){
- result = "extremely underweight";
- gainlose = low_normal - weight;
- }
- else if (15.0 <= bmi && bmi < 18.5){
- result = "underweight";
- gainlose = low_normal - weight;
- }
- else if (18.5 <= bmi && bmi < 25.0){
- result = "normal weight";
- }
- else if (bmi <= 30){
- result = "overweight";
- gainlose = weight - high_normal;
- }
- else if (bmi <= 35.0 ){
- result = "obese";
- gainlose = weight - high_normal;
- }
- else if (bmi > 35){
- result = "extremely obese";
- gainlose = weight - high_normal;
- }
- if (bmi < 18.5)
- System.out.printf("Your BMI is %.2f and that mean %s you have to gain %.2f%n",bmi,result,gainlose);
- else if (18.5 <= bmi && bmi < 25.0)
- System.out.printf("Your BMI is %.2f and that mean %s%n",bmi,result);
- else if (bmi > 25)
- System.out.printf("Your BMI is %.2f and that mean %s you have to lose %.2f%n",bmi,result,gainlose);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement