// CSE 142, Autumn 2009, Marty Stepp // This program computes two people's body mass index (BMI) and // compares them. The code uses parameters, returns, and Scanner. // // This version of the program is incomplete. BMI2.java is the full version. import java.util.*; // so that I can use Scanner public class BMI { public static void main(String[] args) { System.out.println("This program reads in data for two people and"); System.out.println("computes their body mass index (BMI)"); System.out.println(); Scanner console = new Scanner(System.in); person(console); person(console); } // Processes one of the two people. public static void person(Scanner console) { System.out.println("Enter next person's information:"); System.out.print("height (in inches)? "); double height = console.nextDouble(); System.out.print("weight (in pounds)? "); double weight = console.nextDouble(); double bodyMass = bmi(height, weight); System.out.println("Person's BMI = " + bodyMass); } // Computes and returns a person's BMI for the given height and weight. public static double bmi(double height, double weight) { double result = weight / (height * height) * 703; return result; } }