0% found this document useful (0 votes)
41 views3 pages

Body Mass Index (BMI) Calculator: Motaz Malik Lab Test 1 29/3/2016 Matric No. LSEZ4-09/15-00027 Programming 1 IPR1263

The document describes a C++ program written by Motaz Malik for a programming lab test. The program calculates a user's Body Mass Index (BMI) based on their inputted weight in kilograms and height in meters. It uses a do-while loop to repeatedly calculate the BMI using the formula of weight divided by height squared, and then outputs the BMI value and whether the user is underweight, normal, or overweight. It also prompts the user to input their information again or exit the program. Screenshots show the looping of the program and the BMI calculator in use.

Uploaded by

Motaz Ejaz Malik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views3 pages

Body Mass Index (BMI) Calculator: Motaz Malik Lab Test 1 29/3/2016 Matric No. LSEZ4-09/15-00027 Programming 1 IPR1263

The document describes a C++ program written by Motaz Malik for a programming lab test. The program calculates a user's Body Mass Index (BMI) based on their inputted weight in kilograms and height in meters. It uses a do-while loop to repeatedly calculate the BMI using the formula of weight divided by height squared, and then outputs the BMI value and whether the user is underweight, normal, or overweight. It also prompts the user to input their information again or exit the program. Screenshots show the looping of the program and the BMI calculator in use.

Uploaded by

Motaz Ejaz Malik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Motaz Malik

Matric No. LSEZ4-09/15-00027

Lab Test 1
Programming 1

Body Mass Index (BMI)


Calculator
//Motaz Malik "LAB Test"

#include<iostream>
#include<iomanip>
#include<math.h>

using namespace std;

int main()

{
float weight;
float height;
float bmi;
char response;

do
{
cout << "*****************************\n";
cout << "Please enter your weight (KG): ";
cin >> weight;
cout << "Please enter your height (Meters): ";
cin >> height;
bmi = (weight / pow(height,2)) ;
cout<<"\n";

29/3/2016
IPR1263

Motaz Malik
Matric No. LSEZ4-09/15-00027

Lab Test 1
Programming 1

cout << fixed << showpoint << setprecision(2);


cout<<"Your BMI is " << bmi << endl;

if (bmi < 18.5)


{
cout << "You are underweight!" << endl;
cout << "Eat more!!" << endl;
}
else if (bmi >= 18.5 && bmi <25)
cout << "You are normal!"<<endl;
else if (bmi >= 25 )
cout << "You are overweight!"<<endl;
else
cin.get();

cin.get();
cout << endl;

cout << "Would you like to enter the information again? ";
cin >> response;
}
while (toupper(response) == 'Y');
cout << "Okay, see you next time.." << endl;
return 0;
}

SNAP SHOTS OF BMI CALCULATOR

29/3/2016
IPR1263

Motaz Malik
Matric No. LSEZ4-09/15-00027

LOOPING OF PROGRAM

Lab Test 1
Programming 1

29/3/2016
IPR1263

You might also like