WRITTEN IN C# - VISUAL STUDIO WRITTEN IN C# - VISUAL STUDIO 5. (Body Mass Index
ID: 3727231 • Letter: W
Question
WRITTEN IN C# - VISUAL STUDIO
WRITTEN IN C# - VISUAL STUDIO
5. (Body Mass Index Calculator) Repeat to calculate Body Mass Index for five time. (20 points) The formulas for calculating the body mass index (BMI) are weight In Pounds × 703 height!nInches× height!nlnches BMI = Create a BMI calculator program that asks the user to input his/her weight in pounds and height in inches. If either of them is zero or negative, stop the loop immediately. Otherwise, calculate and display the user's body mass index. Other than the value of BMI, the program should also display a message according to the information from the Department of Health and Human Services/National Institutes of Health BMI VALUES Underweight: less than 18.5 Normal: Overweight: between 25 and 29.9 Obese: between 18.5 and 24.9 30 or greater That is, if a user's BMI valueExplanation / Answer
import java.io.*;
import java.lang.*;
class BmiCalc {
public static void main(String args[]) throws IOException {
float h, w, bmi;
try {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("enter the weight(in kgs):");
w = Float.parseFloat(br.readLine());
System.out.println("enter the height(in meters):");
h = Float.parseFloat(br.readLine());
bmi = w / (h * h);
System.out.println("your BMI(body mass index) value is" + bmi);
System.out.println("if your BMI is '<18' you are under weight");
System.out.println("if your BMI is in between '18 and 24 ' you are normal weight");
System.out.println("if your BMI is '>25' you are under weight");
System.out.println("if your BMI is '>30' you are suffering from obesity");
} catch (NumberFormatException a)
{
System.out.println(a);
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.