// InteractiveBMI.java // CS 101 class example // calculates the BMI based on height and weight entered by the user public class InteractiveBMI { public static void main(String[] args) { if (args.length != 2 ) { System.out.println("Usage: java InteractiveBMI "); } else { double height = Double.parseDouble(args[0]); // in inches double weight = Double.parseDouble(args[1]); // in pounds // compute BMI double bmi = weight / (height * height) * 703; // print results p("Height: " + height); p("Weight: " + weight); p("BMI: " + bmi); commentOnBmi(bmi); } } public static void commentOnBmi (double currentBMI) { if (currentBMI < 18.5) { p("You seem to be underweight."); } else if (currentBMI > 24.9) { p("You seem to be overweight."); } else { p("You seem to be just right. :)"); } } public static void p (String s) { System.out.println(s); } }