4) Suppose BMI = WeightInKilos/(HeightInMetres X HeightInMetres). Design and code a BMI calculator in C++ that will read a person’s weight and height and displays the person’s BMI. Before the person’s BMI is displayed, the following information should be shown:
BMI VALUES
Underweight: less than 18.5
Normal: between 18.5 and 24.9
Overweight: between 25 and 29.9
Obesse: 30 and above
2n
Cbest
P(x) = anxn +….+ a0
1
Expert's answer
2017-07-06T12:04:07-0400
#include <iostream>
using namespace std;
int main() { double weightInKilos, heightInMetres, BMI; cout << "This is a BMI calculator!\n"; cout << "BMI VALUES\n"; cout << "Underweight: less than 18.5\n"; cout << "Normal: between 18.5 and 24.9\n"; cout << "Overweight: between 25 and 29.9\n"; cout << "Obesse: 30 and above\n\n"; cout << "Prompt a person weight in kilos: "; cin >> weightInKilos; cout << "Prompt a person height in metres: "; cin >> heightInMetres; if (!heightInMetres) { cout << "Invalid value of height!\n"; return 0; } BMI = weightInKilos / (heightInMetres * heightInMetres); cout << "You BMI is " << BMI << endl;
Comments
Leave a comment