/* * BMI.java * * * Computer Science 112, Boston University * * BMI - a class representing Body Mass Index calculation based on height in inches and weight in pounds. */ public class BMI { // Fields to store height and weight private double height; // Height in inches private double weight; // Weight in pounds /* * Constructor to initialize height and weight * Parameters: * - heightInInches: a double representing the height in inches * - weight: a double representing the weight in pounds */ public BMI(double height, double weight) { this.height = height; this.weight = weight; } /* * Getter method to retrieve the height in inches * Returns: a double representing the height in inches */ public double getHeight() { return height; } /* * Setter method to set the height in inches * Parameters: * - heightInInches: a double representing the new height in inches */ public void setHeight(double heightInInches) { this.height = heightInInches; } /* * Getter method to retrieve the weight in pounds * Returns: a double representing the weight in pounds */ public double getWeight() { return weight; } /* * Setter method to set the weight in pounds * Parameters: * - weight: a double representing the new weight in pounds */ public void setWeight(double weight) { this.weight = weight; } /* * Method to calculate the Body Mass Index (BMI) * Returns: a double representing the calculated BMI */ public double calculateBMI() { // BMI formula for inches and pounds: (weight / (height * height)) * 703 return (weight / (height * height)) * 703; } }