Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a Java class that calculates BMI. Your program should have the following

ID: 3758573 • Letter: C

Question

Create a Java class that calculates BMI. Your program should have the following fields:

name

height in meters

mass in kilograms

The BMI formula is as follows:

How BMI relates to fitness is specified in the following chart:

Your BMI class should have two general methods and a toString method. The first general method should calculate BMI and return it as a float. The second general method should accept a BMI as a parameter and return a string that is the category for that BMI from the table above.

Category BMI range (kg/m2) Very severely underweight less than 15 Severely underweight from 15.0 to 16.0 Underweight from 16.0 to 18.5 Normal (healthy weight) from 18.5 to 25 Overweight from 25 to 30 Obese Class I (Moderately obese) from 30 to 35 Obese Class II (Severely obese) from 35 to 40 Obese Class III (Very severely obese) over 40

Explanation / Answer

class BMI{
   private double height;
   private double kg;
   private string name;
   public void calculateBMI(){
       return kg/(height*height);
   }
   public String toString(double bmi){
       if(bmi < 15)
           System.out.println("Very severely underweight");
       else if(bmi > 15 && bmi < 16)
           System.out.println("Severely underweight");
       else if(bmi > 16 && bmi < 18.5)
           System.out.println("Underweight");
       else if(bmi > 18.5 && bmi < 25)
           System.out.println("Normal (healthy weight)");
       else if(bmi > 25 && bmi < 30)
           System.out.println("Overweight");
       else if(bmi > 30 && bmi < 35)
           System.out.println("Obese Class I (Moderately obese)");
       else if(bmi > 35 && bmi < 40)
           System.out.println("Obese Class II (Severely obese)");
       else
           System.out.println("Obese Class III (Very severely obese)");      
   }
}