// This program computes a person's body mass index (BMI). // Also see the BMI2 program for a larger example that computes // two people's BMIs and uses more parameters and returns. import java.util.*; // so that I can use Scanner public class BMI1 { public static void main(String[] args) { Scanner console = new Scanner(System.in); 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 bmi1 = getBMI(height, weight); System.out.println("Person #1 body mass index = " + bmi1); } // Computes a person's body mass index based on their height and weight // and returns the BMI as its result. public static double getBMI(double height, double weight) { double bmi = weight / (height * height) * 703; return bmi; } }