NEEDED IN C# Obesity has become a serious health problem in our society. The Bod
ID: 3662659 • Letter: N
Question
NEEDED IN C#
Obesity has become a serious health problem in our society. The Body Mass Index (BMI) is a measure of the weight of a person scaled according to height.
It is defined as BMI = 703 * weight / (height * height)
The weight is measured in pounds and the height is in inches. For example, a 150 pounds, 66 inches person has a BMI of 703 * 150 / (66 * 66) = 24.21.
Based on the BMI we can determine the body weight category of a person:
If BMI is in this range: Body weight category will be: under 18.5 underweight
18.5 to under 25 normal
25 to under 30 overweight
30 or above obese
Create a C# console application that asks for the weight and height of a person. The program should display the BMI and the body weight category of the person.
Explanation / Answer
Answer :
using System;
public static class GlobalMembersBmi
{
public static double Bodymassindex(int bodyheight, int bodyweight)
{
return (double)(bodyweight * 703 / (bodyheight * bodyheight));
}
static int Main()
{
double bmi = 0;
int bodyweight;
int heightinInches;
int heightinFeet;
int totalbodyheight;
Console.Write("Enter your weight: ");
bodyweight = int.Parse(ConsoleInput.ReadToWhiteSpace(true));
Console.Write("Please Enter your height in feet: ");
heightinFeet = int.Parse(ConsoleInput.ReadToWhiteSpace(true));
Console.Write("Please Enter your height in inches: ");
heightinInches = int.Parse(ConsoleInput.ReadToWhiteSpace(true));
totalbodyheight = (heightinFeet * 12) + heightinInches;
bmi = Bodymassindex(totalbodyheight, bodyweight);
Console.Write("You Body Mass Index is: ");
Console.Write(bmi);
Console.Write(" ");
Console.Write("Underweight: less than 18.5");
Console.Write(" ");
Console.Write("Normal weight: 18.5 - 25.0");
Console.Write(" ");
Console.Write("Overweight: 25 - 30.0");
Console.Write(" ");
Console.Write("Obese: 30 or greater");
Console.Write(" ");
Console.Read();
return 0;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.