Advertisement
binibiningtinamoran

bmipart2

Jul 2nd, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.31 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Mission08Western {
  4.  
  5.     public static void main(String []args) {
  6.  
  7.         Scanner scan = new Scanner(System.in);
  8.  
  9.         System.out.print("Enter height in inches: ");
  10.         double height = scan.nextDouble();
  11.  
  12.         while (height < 0.0) {
  13.             System.out.print("Enter height in inches: ");
  14.             height = scan.nextDouble();
  15.         }
  16.  
  17.         System.out.print("Enter weight in inches: ");
  18.         double weight = scan.nextDouble();
  19.  
  20.         while (weight < 0.0) {
  21.             System.out.print("Enter weight in inches: ");
  22.             weight = scan.nextDouble();
  23.         }
  24.  
  25.         double BMI = (weight * 703) / (height * height);
  26.         System.out.printf("Your BMI is %,.2f.\n", BMI);
  27.  
  28.         if (BMI < 18.5) {
  29.             System.out.println("Your are underweight.\n");
  30.         } else if (BMI >= 18.5 && BMI <= 24.9) {
  31.             System.out.println("You have normal weight.\n");
  32.         } else if (BMI >= 25 && BMI <= 29.9) {
  33.             System.out.println("You are overweight!" +
  34.                     "\nTime to lose some pounds bruh!");
  35.         } else if (BMI >= 30) {
  36.             System.out.println("You are obese." +
  37.                     "\nPlease talk to your physician.");
  38.         } else {
  39.             System.exit(0);
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement