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

I have already done this program, and it works just fine. However, I need to add

ID: 3638643 • Letter: I

Question

I have already done this program, and it works just fine. However, I need to add the following criteria to the program and I am not sure how to go about doing it. Any help would be appreciated.

Methods
Write a program to ask the user for their weight (in lbs) and height (in inches) and display a message indicating whether a person has optimal weight, is underweight or is overweight according to their Body Mass Index (BMI).

BMI = (weight in lbs) *703 / (height in inches)2. A BMI under 18.5 is considered underweight. A BMI over 25 is considered overweight. Be sure to display the BMI as part of the output. E.g.,: “At a BMI of 27.2, you are over weight” or “At a BMI of 20.1, you are normal weight”

This time use the following methods to do the work:
public static double getDoubleInput(string prompt);

public static double computeBMI(double weight, double height);

public static boolean isUnderWeight(double bmi);

public static boolean isOverWeight(double bmi);

public static boolean isNormalWeight(double bmi);

- may not be needed public static void displayOutput(double bmi, String weightStatus);

Here is my old program:


import java.util.Scanner;


public class BmiCaclulation {

/**
* @param args
*/
public static void main(String[] args) {
double height = 0.0;
double weight = 0.0;
double bmi;

Scanner keyboard = new Scanner(System.in);

System.out.println("How tall are you in inches?");

height = keyboard.nextDouble();

System.out.println("What is your weight?");

weight = keyboard.nextDouble();

bmi = ((weight / (height * height) * 703));

if (bmi < 18.5) {
System.out.println("You are underweight.");
} else if (bmi < 25) {
System.out.println("Your weight is normal.");
} else if (bmi < 30) {
System.out.println("You are overweight.");
} else {
System.out.println("You are obese.");
}


}

}

Explanation / Answer

Dear,

public class BmiCaclulation
{

    public static void main(String[] args)
    {
        // TODO Auto-generated method stub
        double height = 0.0;
        double weight = 0.0;
        double bmi;
        String input,weightStatus;
        Scanner keyboard = new Scanner(System.in);
        //Input height
        System.out.println("How tall are you in inches?");
        input = keyboard.nextLine();
        height = getDoubleInput(input);
       
       //Input weight
        System.out.println("What is your weight?");
        input = keyboard.nextLine();
        weight = getDoubleInput(input);

        bmi = computeBMI(weight,height);

        if (isUnderWeight(bmi))
        {
            weightStatus="You are underweight.";
        }
        else if (isNormalWeight(bmi))
        {
            weightStatus="Your weight is normal.";
        }
        else if (isOverWeight(bmi))
        {
            weightStatus="You are overweight.";
        }
        else
        {
            weightStatus="You are obese.";
        }
        displayOutput(bmi,weightStatus);
    }
    public static double getDoubleInput(String prompt)
    {
        double input;
        String str;
        input=Double.parseDouble(prompt);
        return input;
    }

    public static double computeBMI(double weight, double height)
    {
        return ((weight / (height * height) * 703));
       
    }

    public static boolean isUnderWeight(double bmi)
    {
        if (bmi < 18.5)
        return true;   
       
        else
            return false;
    }

    public static boolean isOverWeight(double bmi)
    {
       if (bmi < 30)
        return true;   
       
        else
            return false;
    }

    public static boolean isNormalWeight(double bmi)
    {
        if (bmi < 25)
            return true;   
           
            else
                return false;
    }
   
    public static void displayOutput(double bmi, String weightStatus)
    {
        System.out.print("BMI:"+bmi);
        System.out.print("Status:"+weightStatus);
    }

}

Hope this will help you!!


Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote