Question

/////////////////////////////////////////////////////////////////////////////////// //This program // 1. asks the user her/his weight and height // 2. then calculates...

///////////////////////////////////////////////////////////////////////////////////
//This program 
// 1. asks the user her/his weight and height
// 2. then calculates the user's body-mass-index (BMI) 
// 3. and then prints an appropriate message based on the user's BMI
///////////////////////////////////////////////////////////////////////////////////

#include <iostream>
using namespace std;

void printWelcome();

// ask the weight (in pounds) and height (in inches) of the user and store the values in formal
// parameters weight and height, respectively
void getWeightAndHeight(float& weight, float& height);

// calculate and return the BMI (Body-Mass-Index) based on the user's weight and height
float calculateBMI(float weight, float height);

// print a message to the user based on the user's BMI passed by the formal
// parameter bmi. 
// -------------------------------------------------------------------------
// Use the following BMI Categories to print an appropriate message to the user
// -----------------------------------------------------------------------
// Underweight if BMI =<18.5
// Normal weight if BMI is between 18.5 and 24.9
//      Overweight if BMI is between 25 and 29.9
// Obesity  if BMI of 30 or greater
void printReport(float bmi);

int main()
{
        float  w, h;

        // 0. Welcome
        printWelcome();

        ///////////////////////////////////////////////////////////////////////
        // TO-DO: 
        // - Complete the main program by calling the appropriate functions
        // appropriately
        // - Note that you must also complete the body of the functions below
        ///////////////////////////////////////////////////////////////////////

        // 1. ask the user her/his weight and height: call the getWeightAndHeight() function
        getWeightAndHeight(w, h);

        // 2. calculate the user's body-mass-index (BMI): call the calculateBMI() function 
        // ...

        // 3. print an appropriate message based on the user's BMI: call printReport() function
        // ...



        system("pause");
        return 0;
}

void printWelcome() {
        cout << "___________________________________________________________________________\n"
                << "This program \n"
                << " 1. asks the user her/his weight and height \n"
                << " 2. then calculates the user's body-mass-index (BMI) \n"
                << " 3. and then prints an appropriate message based on the user's BMI \n"
                << "___________________________________________________________________________\n\n";

}

// ask the weight (in pounds) and height (in feet) of the user and store the values in formal
// parameters weight and height, respectively
void getWeightAndHeight(float& weight, float& height) {
        // complete the body of this function
        //...
}

// calculate and return the BMI (Body-Mass-Index) based on 
// the user's weight (in pounds) and height (in inches)
// reference: http://extoxnet.orst.edu/faqs/dietcancer/web2/twohowto.html
float calculateBMI(float weight, float height) {
        // complete the body of this function
        //...
        return 0.0; // also fix this line
}

// print a message to the user based on the user's BMI passed by the formal
// parameter bmi. 
// -------------------------------------------------------------------------
// Use the following BMI Categories to print an appropriate message to the user
// -----------------------------------------------------------------------
// Underweight if BMI =<18.5
// Normal weight if BMI is between 18.5 and 24.9
//      Overweight if BMI is between 25 and 29.9
// Obesity  if BMI of 30 or greater
void printReport(float bmi) {
        // complete the body of this function
        //...

}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<iostream>
#include<cmath>

using namespace std;

float weight, height, BMI; //global declaration of weight, height and BMI variables. since we are using these varaibles throughout program, i have declared as global

//This method Prints Welcome Message to user
void printWelcome(){
cout << "___________________________________________________________________________\n"
<< "This program \n"
<< " 1. asks the user her/his weight and height \n"
<< " 2. then calculates the user's body-mass-index (BMI) \n"
<< " 3. and then prints an appropriate message based on the user's BMI \n"
<< "___________________________________________________________________________\n\n";
}

//This method takes inputs from user i.e weight and height and stores in weight and height variables respectively
void getWeightAndHeight() {
cout << "\n++++++++++++++++++++++++++++++++++++\n"
<< " Body Mass Index"
<< "\n++++++++++++++++++++++++++++++++++++\n";

cout << "Enter your weight (in pounds): ";
cin >> weight;
cout << "\nEnter your height (in inches): ";
cin >> height;

  
}

// This methid calculates BMI ased on weight and height given by user
float calculateBMI(float w, float h){
float weightAfterMetricConversion = (w*0.45); //weight Metric conversion as per URL given in the question
float heightAfterMetricConversion = (h*0.025); //height Metric conversion as per URL given in the question
float bmi = (weightAfterMetricConversion) / (heightAfterMetricConversion * heightAfterMetricConversion); //calculating BMI
return bmi;
}

//This method prints final report based on various conditions for BMI
void printReport(float bmi){
if(bmi <= 18.5)
cout << "Underweight\n\n";
if(bmi > 18.5 && bmi <= 24.9)
cout << "Normal Weight\n\n";
if(bmi > 25 && bmi <=29.9)
cout << "Overweight\n\n";
if(bmi > 30)
cout << "Obesity\n\n";
  
}

int main()
{
printWelcome(); //calling printWelcome method
getWeightAndHeight(); //calling getWeightAndHeight method
float BMI = calculateBMI(weight, height); // calling calculateBMI method and storing return value in BMI variable
printReport(BMI); //calling printReport method

system("pause");

return 0;
}

Sample Input and Output :

This program 1. asks the user her/his weight and height 2. then calculates the user s body-mass-index (BMI) 3. and then prin

Program snapshot :

#1 nclude<\ostream> #1 ncl ude<cmath> using namespace std; float weight, height, EMI; //global declaration of weight, height

Add a comment
Know the answer?
Add Answer to:
/////////////////////////////////////////////////////////////////////////////////// //This program // 1. asks the user her/his weight and height // 2. then calculates...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Body Mass Index Calculator

    Create a BMI calculator applications that reads the user's weight in kilograms and height in meters, then calculates and displays the user's body mass index.Also, the application should display the following information from the Department of Health and Human Services, so the user can evaluate his/her BMI:BMI ValuesUnderweight: less that 18.5Normal: between 18.5 and 24.9Overweight: between 25 and 29.9Obese: 30 or greaterFormula for calculating BMI areBMI = weightInKilogramsheightInMeters x heightInMetersThe program is to be written in C++ langauge.I need some...

  • read instructions carefully please matlab only Write a MATLAB function for a BMI calculator that receives the inputs for body weight (lbs)and height (ft) from the user's program, calculates th...

    read instructions carefully please matlab only Write a MATLAB function for a BMI calculator that receives the inputs for body weight (lbs)and height (ft) from the user's program, calculates the BMI using the equation below, displays the BMI category, and outputs the BMI value tothe user's program W (kg) h2 (m2) BMI Display Normal if 18.5 s BMI 25 Display Overweight if 25 s BMI <30 Display Obese if BMI 2 30 Else display underweight So you will create two...

  • Write a Java program that performs these operations Prompt the user to enter a low height...

    Write a Java program that performs these operations Prompt the user to enter a low height in feet (an integer) Prompt the user to enter a high height in feet (an integer) Prompt the user to enter a low weight in pounds (an integer) Prompt the user to enter a high weight in pounds (an integer) Print a table of Body Mass Index (BMI) for the heights and weights entered, ranging from the low height to the high height (inclusive),...

  • python2.7 25 Points. Create a class named BMIGUI with the following behavior. A template has been...

    python2.7 25 Points. Create a class named BMIGUI with the following behavior. A template has been provided for you and you cannot modify the template. You must use grid) to format the interface and you must get as close as possible the layout shown below. The entry box has a width parameter in its constructor you can use to make the box smaller 3. The BMI categories are as follows: Underweight= <18.5 Normal weight18.5-24.9 . Overweight 25-29.9 Obese BMI of...

  • Using JAVAFX The application will calculate Body Mass Index (BMI) for people. It must be able...

    Using JAVAFX The application will calculate Body Mass Index (BMI) for people. It must be able to accept as input weights (in pounds or kilos), and height (in inches or centimeters). The application should have a calculate button, and should display the result as well as if the data puts the person in one of 4 categories underweight ( BMI < 18.5) , normal weight (BMI 18.5-24.9), overweight (BMI 25.0 - 29.9) or overweight (BMI > 30) For full credit...

  • You are working as a software developer for a large insurance company. Your company is planning...

    You are working as a software developer for a large insurance company. Your company is planning to migrate the existing systems from Visual Basic to Java and this will require new calculations. You will be creating a program that calculates the insurance payment category based on the BMI score. Your Java program should perform the following things: Take the input from the user about the patient name, weight, birthdate, and height. Calculate Body Mass Index. Display person name and BMI...

  • OGICAL 28. Body mass index (BMI) is a measure of obesity. In standard units, it is...

    OGICAL 28. Body mass index (BMI) is a measure of obesity. In standard units, it is calculated by the formula EMENTS BMI = 7032 ATEMENT NESTED INTS where Wis weight in pounds, and His height in inches. The obesity classification is BMI Classification Below 18.5 Underweight 18.5 to 24.9 Normal 25 to 29.9 Overweight 30 and above Obese Tue Write a program in a script file that calculates the BMI of a person. The program asks the person to enter...

  • Using C++ cs 102 REVIEW LAB Selection a) Minimum/Maximum: Nrite a program that asks the user...

    Using C++ cs 102 REVIEW LAB Selection a) Minimum/Maximum: Nrite a program that asks the user to enter two numbers. The progzan should use the conditional operator to determine which number is the smaller and which is the larger. Display your output in the format below: The smaller number is: (smallerNumber) The larger number is: ClargerNumber] b) Areas of Rectangles: The area of a rectangle is calculated by maltiplying its length tines its width. Write a program that asks the...

  • Write a C program that reads the height and weight of a person and calculates the...

    Write a C program that reads the height and weight of a person and calculates the body mass index (bmi) according to formula bmi = weight/(height)2. Your program should display a qualitative assessment of the weight according to the following table: BMI value Letter Grade [0-20) Below normal weight [20-25) Normal weight [25-30) Overweight >=30 Obese Sample Output: Enter your weight in kilos: 70 Enter your height in meters: 1.80 Result: Normal weight Test values: (70 1.8) (50, 1.9) (90,...

  • Weight: 131 lbs Female Height: 5 ft 2 inches Calculate, showing the math, your Body Mass...

    Weight: 131 lbs Female Height: 5 ft 2 inches Calculate, showing the math, your Body Mass Index (BMI) using the formula 'weight in kilograms divided by height in meters squared' (kg/m^2). Note: Weight in pounds divided by 2.2 = weight in kg and height in inches times .0254 = height in meters. The number is absolute and not a percentage. Based on your BMI, are you underweight, healthy weight, overweight, or obese?

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT