// CSE 142, Autumn 2010 // Author: Jessica Miller // This program computes two people's body mass index (BMI). // The code uses parameters, returns, and Scanner. import java.util.*; // for Scanner public class BMI { public static void main(String[] args) { Scanner console = new Scanner(System.in); System.out.println("This program reads in data for two people and"); System.out.println("computes their body mass index (BMI)"); System.out.println(); processPerson(1, console); processPerson(2, console); } public static void processPerson(int number, Scanner console) { System.out.println("Enter next person's info: "); System.out.print("height (in inches)? "); double height = console.nextDouble(); System.out.print("weight (in lbs)? "); double weight = console.nextDouble(); double bmi1 = calculateBMI(height, weight); System.out.println("Person " + number + " BMI = " + bmi1); if (bmi1 < 18.5) { System.out.println("underweight"); } else if (bmi1 <= 24.9) { System.out.println("normal"); } else if (bmi1 <= 29.9) { System.out.println("overweight"); } else { System.out.println("obese"); } } public static double calculateBMI(double height, double weight) { double bmi = weight / Math.pow(height, 2) * 703; return bmi; } }