Question

In: Computer Science

The Body Mass Index (BMI) is a calculation used to categorize whether a person’s weight is...

The Body Mass Index (BMI) is a calculation used to categorize whether a person’s weight is at a healthy weight for a given height. The formula is as follows:

                bmi = kilograms / (meters2)

                where kilograms = person’s weight in kilograms, meters = person’s height in meters

BMI is then categorized as follows:

Classification

BMI Range

Underweight

Less than 18.5

Normal

18.5 or more, but less than 25.0

Overweight

25.0 or more, but less than 30.0

Obese

30.0 or more

To convert inches to meters:

                meters = inches / 39.37

To convert pounds (lbs) to kilograms:

                kilograms = lbs / 2.2046

Assignment

Ask the user for their weight in pounds and height in inches. Compute their BMI and BMI classification and output the results.

The program must implement and use the following methods:

convertToKilograms – convert pounds to kilograms

convertToMeters – convert inches to meters

calcBMI – take weight in kilograms and height in meters and return the BMI

bmiClassification – take the value for the BMI and return a String with the BMI classification

Use the following code as a starting point for your assignment:

import java.util.Scanner;

// TODO Student name, date, purpose
public class Main {

    private static Scanner input = new Scanner(System.in);

    public static void main(String[] args) {
        double lbs, inches, meters, kgs, bmi;
        String classification;

       // TODO add code here
   
}

   // TODO add your methods here (make them static)
}

As always use the package name edu.cscc and include a comment with your name, the date, and the purpose of the program.

Example Output

Calculate BMI

Enter weight (lbs): 200

Enter height (inches): 72

Your BMI is 27.124767811523153

Your BMI classification is Overweight

Solutions

Expert Solution

  • Following is the code in JAVA.
  • Comments have been added in order to make it understood.


import java.util.Scanner;

// TODO Student name, date, purpose
public class Main {

private static Scanner input = new Scanner(System.in);

public static void main(String[] args) {
double lbs, inches, meters, kgs, bmi;
String classification;
  
// TODO add code here
// Taking input
System.out.print("Enter weight (lbs): ");
lbs = input.nextDouble();
System.out.print("Enter height (inches): ");
meters = input.nextDouble() * 0.0254;  
// Converting pounds to kgs
kgs = lbs/2.2;
// Calculation of BMI
bmi = calculateBMI(kgs, meters);
// Classification of bmi
classification = classify(bmi);
  
System.out.println("Your BMI is " + bmi);
System.out.println("Your BMI classification is " + classification);
}

// TODO add your methods here (make them static)
public static double calculateBMI(double weight, double height) {
   return weight/ (height*height);
}
// Classify the BMI to string
public static String classify(double bmi) {
   if(bmi < 18.5) {
       return "Underweight";
   }else if(bmi < 25.0) {
       return "Normal";
   }else if(bmi < 30.0) {
       return "Overweight";
   }else {
       return "Obese";
   }
}
}

Following is the snippet of the same.

That was a nice question to answer
Friend, If you have any doubts in understanding do let me know in the comment section. I will be happy to help you further.
Please like if you think effort deserves like.
Thanks


Related Solutions

programming in Python The body mass index (BMI) is calculated as a person’s weight (in lb)...
programming in Python The body mass index (BMI) is calculated as a person’s weight (in lb) times 720, divided by the square of the person’s height (in inches). A BMI in the range 19-25, inclusive, is considered healthy. Write a program that inputs people’s weight and height, then calculates a person’s BMI and print a message telling whether they are above, within, or below the healthy range. A formula for computing Easter in the years 1982-2048, inclusive, is as follows:...
The Body Mass Index (BMI) is a value calculated based on the weight and the height...
The Body Mass Index (BMI) is a value calculated based on the weight and the height of an individual. In a small European city, a survey was conducted one year ago to review the BMI of the citizens. In the sample 22 with 200 citizens, the mean BMI was 23.3 kg/m and standard deviation was 1.5 kg/m . It is reasonable to assume the BMI distribution is a normal distribution. (a) Find the point estimate of the population mean BMI...
The Body Mass Index (BMI) is a value calculated based on the weight and the height...
The Body Mass Index (BMI) is a value calculated based on the weight and the height of an individual. In a small European city, a survey was conducted one year ago to review the BMI of the citizens. In the sample with 200 citizens, the mean BMI was 23.3 kg/m2 and standard deviation was 1.5 kg/m2 . It is reasonable to assume the BMI distribution is a normal distribution. (a) Find the point estimate of the population mean BMI one...
Question 2 The Body Mass Index (BMI) is a value calculated based on the weight and...
Question 2 The Body Mass Index (BMI) is a value calculated based on the weight and the height of an individual. In a small European city, a survey was conducted one year ago to review the BMI of the citizens. In the sample with 200 citizens, the mean BMI was 23.3 kg/m2 and standard deviation was 1.5 kg/m2 . It is reasonable to assume the BMI distribution is a normal distribution. (a) Find the point estimate of the population mean...
Using class, write a program that: Body Mass Index (BMI) calculation - write a program that...
Using class, write a program that: Body Mass Index (BMI) calculation - write a program that takes users' input (weight and Height) and calculates the BMI. If the result is less than 18.5 display "you are underweight", if the result is greater than 18.5 display "you have a normal weight", if the result is greater than 24.9 display "your weight is considered overweight", and the result is greater than 30 display "your weight is considered as obese" (BMI = 703...
Question Number 13 A Scientist is researching whether or not body mass index (BMI) to the...
Question Number 13 A Scientist is researching whether or not body mass index (BMI) to the systolic blood pressure(SBP). He collects the random sample of 8 different patients. The results are shown in the table below. Table 8 BMI 21 23 24 25 20 28 26 27 SBP(mm Hg) 118 114 119 131 111 124 117 118 a. Draw a scatter diagram b. Explain why a linear regression model may be appropriate to describe the relationship between BMI and SBP....
please show work Body mass index (BMI) is computed as the ratio of weight in kilograms...
please show work Body mass index (BMI) is computed as the ratio of weight in kilograms to the square of the height in meters.  The distribution of BMI is approximately normal for females aged 30-39. In this group, the mean BMI is 24.5, with a standard deviation of 3.3. 13) What proportion of females aged 30-39 has a BMI of 25 or more? 14) Persons with a BMI of 30 or greater are considered obese.  What proportion of females aged 30-39 is...
Discuss the process of calculating Body Mass Index (BMI).
Discuss the process of calculating Body Mass Index (BMI).
The body mass index​ (BMI) for a sample of men and a sample of women are...
The body mass index​ (BMI) for a sample of men and a sample of women are given below. Assume the samples are simple random samples obtained from populations with normal distributions. Men 30.930.9 22.322.3 29.929.9 30.930.9 27.227.2 31.731.7 26.526.5 20.220.2 26.626.6 30.530.5 Women nbspWomen 18.218.2 20.720.7 22.222.2 28.428.4 17.117.1 20.320.3 23.923.9 31.831.8 20.820.8 20.720.7 LOADING... Click the icon to view the table of​ Chi-Square critical values. a. Construct aa 9090​% confidence interval estimate of the standard deviation of BMIs for...
Design a modular program that calculates and displays a person's body mass index (BMI). The BMI...
Design a modular program that calculates and displays a person's body mass index (BMI). The BMI is often used to determine whether a person with a sedentary lifestyle is overweight or underweight for his or her height. A person's BMI is calculated with the following formula: BMI=Weight*703/Height^2. I need help making this to Java to just calculate BMI.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT