brilliant_moves

BMICalc.java

Sep 1st, 2015
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.67 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class BMICalc {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner in = new Scanner(System.in);
  7.         int feet, inches, pounds;
  8.         double meters, kilograms, bmi;
  9.  
  10.         System.out.print("Enter your height:\nfeet: ");
  11.         feet = in.nextInt();
  12.         System.out.print("inches: ");
  13.         inches = in.nextInt();
  14.         System.out.print("What is your weight? (in pounds): ");
  15.         pounds = in.nextInt();
  16.  
  17.         meters = (inches + (feet * 12)) * 0.0254;
  18.         kilograms = pounds / 2.2;
  19.         bmi = kilograms / (meters * meters);
  20.  
  21.         System.out.printf("A %d foot by %d inch adult of %d pounds has a BMI of %.1f%n",
  22.          feet, inches, pounds, bmi);
  23.     } // main()
  24.  
  25. } // class BMICalc
Advertisement
Add Comment
Please, Sign In to add comment