Advertisement
grodek118

BMI Calculator

Sep 22nd, 2022 (edited)
868
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.86 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.  
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         double bmi;
  10.         double weight;
  11.         double height;
  12.         double powHeight;
  13.  
  14.         System.out.println("Enter your weight (in pounds)");
  15.         weight = scanner.nextDouble();
  16.         System.out.println("Enter your height (in inches)");
  17.         height = scanner.nextDouble();
  18.  
  19.         powHeight = Math.pow(height, 2.0);
  20.  
  21.         bmi = weight * 703 / powHeight;
  22.  
  23.         System.out.println(bmi);
  24.  
  25.         if (bmi > 25)
  26.         {
  27.             System.out.println("You're overweight");
  28.         }
  29.         else if (bmi >= 18.5)
  30.         {
  31.             System.out.println("You're optimal");
  32.         }
  33.         else
  34.         {
  35.             System.out.println("You're underweight");
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement