daniel_lawson9999

Daniel Lawson BMI Calculator

Apr 18th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.38 KB | None | 0 0
  1. /**
  2.  * Created by Daniel on 4/18/2016.
  3.  */
  4. import java.util.*;
  5. public class bmiCalculator {
  6.     public static void main(String[] args){
  7.         Scanner c = new Scanner(System.in);
  8.         System.out.println("This program reads data for two people and");
  9.         System.out.println("computes their body mass index (BMI).\n");
  10.         double person1 = bmi(c);
  11.         double person2 = bmi(c);
  12.         health(person1,1);
  13.         health(person2,2);
  14.         System.out.println("Difference = " + Math.abs(person1 - person2));
  15.  
  16.     }
  17.     public static double bmi(Scanner c){
  18.         System.out.println("Enter next person's information:");
  19.         System.out.print("height (in inches)?");
  20.         double height = c.nextDouble();
  21.         System.out.print("weight (in pounds)");
  22.         double weight = c.nextDouble();
  23.         System.out.println();
  24.         double BMI = (weight/(height*height)) *703;
  25.         return BMI;
  26.     }
  27.     public static void health(double p,int pn){
  28.         System.out.println("Person" + pn + " BMI = "+p + pn);
  29.         if (p >= 30.0){
  30.             System.out.println("Obese");
  31.         }
  32.         if (p >= 25.0 && p <=29.9){
  33.             System.out.println("Overweight");
  34.         }
  35.         if(p >= 18.5 && p <=24.9){
  36.             System.out.println("Normal");
  37.         }
  38.         if(p < 18.5){
  39.             System.out.println("Underweight");
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment