WRITTEN IN C# VISUAL STUDIO WRITTEN IN C# VISUAL STUDIO WRITTEN IN C# VISUAL STU
ID: 3728141 • Letter: W
Question
WRITTEN IN C# VISUAL STUDIO
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
using System;
public class Test
{
public static void Main()
{
double weightInPounds,heightInInches,bmi;
for(int i = 1;i<=5;i++)
{
Console.WriteLine("Enter your weight in pounds : ");
weightInPounds = Convert.ToDouble(Console.ReadLine());
if(weightInPounds <= 0)
break;
Console.WriteLine("Enter your height in inches : ");
heightInInches = Convert.ToDouble(Console.ReadLine());
if(heightInInches <= 0)
break;
bmi = (weightInPounds*703)/(heightInInches*heightInInches); //compute bmi
Console.WriteLine("BMI : "+ Math.Round(bmi,2));
if(bmi < 18.4) // check bmi
Console.WriteLine("UnderWeight");
else if(bmi >= 18.4 && bmi <=24.9)
Console.WriteLine("normal");
else if(bmi >= 25 && bmi <=29.9)
Console.WriteLine("Overweight");
else if(bmi >=30)
Console.WriteLine("Obese");
}
}
}
Output:
Enter your weight in pounds :100.6
Enter your height in inches :62
BMI : 18.4
UnderWeight
Enter your weight in pounds :140.6
Enter your height in inches :67
BMI : 22.02
normal
Enter your weight in pounds :138.8
Enter your height in inches :70
BMI : 19.91
normal
Enter your weight in pounds :150.4
Enter your height in inches :68
BMI : 22.87
normal
Enter your weight in pounds :120.8
Enter your height in inches :56
BMI : 27.08
Overweight
Please upvote if the answer is helpful. Do ask if there are any queries.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.