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

Write a C# two-class solution to calculate and display a person’s body mass inde

ID: 3737433 • Letter: W

Question

Write a C# two-class solution to calculate and display a person’s body mass index (BMI). BMI is an internationally used measure of obesity. Depending on where you live, the Imperial BMI formula or the Metric Imperial Formula is used. Once the BMI is calculated, display a message of the person’s status. Prompt the user for both their weight and height. The BMI status categories, as recognized by the U.S. Department of Health & Human Services, are given in the following table: BMI Weight Status Below 18.5 Underweight 18.5–24.9 Normal 25–29.9 Overweight 30 & above Obese Provide constructors and methods so that both imperial and metric objects can be instantiated. Use the second class to test your design.

Explanation / Answer

Please find my code.

Please rate my Answer if it helped you!!

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication3
{
class BMI
{
double weight;
double height;
public BMI() //default constructor
{
weight = 0;
height = 0;
}
public BMI(double wt,double ht) //parameterized constructor
{
weight = wt;
height = ht;
}
public void input() //function to input height and weight
{
Console.WriteLine("Enter weight in kilograms");
weight = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Enter height in metres");
height = Convert.ToDouble(Console.ReadLine());
}

public void BMIstatus() //function to calculate BMI and display status of person
{
double bmi;
bmi = weight / (height * height);
  
if (bmi<18.5)
Console.WriteLine("Person is Underweight");
else if(bmi>18.5 && bmi<24.9)
Console.WriteLine("Person is normal");
else if(bmi>25 && bmi<29.9)
Console.WriteLine("Person is Overweight");
else if(bmi>=30)
Console.WriteLine("Person is Obese");

}
}
class Program
{
static void Main(string[] args)
{
BMI person1=new BMI();
person1.input(); //call functions
person1.BMIstatus();
Console.ReadLine();

}
}
}

Sample run:

Enter weight in kilograms 70
Enter height in metres 1.57

Person is Overweight

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