Question

In: Computer Science

Language C++ Ask the user to enter their weight (in pounds) and their height in inches....

Language C++

Ask the user to enter their weight (in pounds) and their height in inches. Calculate their Body Mass Index (BMI) and tell them whether they are underweight, overweight, or at optimal weight.

BMI formula: weight * 703 / (height * height)

Optimal weight is a BMI from 19 to 26. Lower is underweight, higher is overweight.

Prompts:

Enter your weight (in pounds): [possible user input: 144]

Enter your height (in inches): [posible user input: 73]

Possible Outputs:

Your BMI is 18.9964, which means you are underweight.

Your BMI is 29.2612, which means you are overweight.

Your BMI is 25.8704, which means you are at optimal weight.

Notes and Hints:

1) For simplicity, assume user entries will be in whole numbers. However, BMI must be calculated with decimals.

2) You must use an if/else if structure for this

Solutions

Expert Solution

C++ code:

#include <iostream>
using namespace std;
int main(){
    //initializing weight,height and BMI
    double weight,height,bmi;
    //asking for weight
    cout<<"Enter your weight (in pounds): ";
    //accepting it
    cin>>weight;
    //asking for height
    cout<<"Enter your height (in inches): ";
    //accepting it
    cin>>height;
    //finding bmi
    bmi=weight*703/(height*height);
    //checking if BMI is less than 19
    if(bmi<19)
    //printing underweight
        cout<<"Your BMI is "<<bmi<<", which means you are underweight."<<endl;
    //checking if BMI is greater than 26
    else if(bmi>26)
    //printing overweight
        cout<<"Your BMI is "<<bmi<<", which means you are overweight."<<endl;
    else
    //printing optimal weight
        cout<<"Your BMI is "<<bmi<<", which means you are at optimal weight."<<endl;
    return 0;
}

Screenshot:


Input and Output:


Related Solutions

Write a program using C language that -ask the user to enter their name or any...
Write a program using C language that -ask the user to enter their name or any other string (must be able to handle multiple word strings) - capture the epoch time in seconds and the corresponding nanoseconds - ask the user to type in again what they entered previously - capture the epoch time in seconds and the corresponding nanoseconds -perform the appropriate mathematical calculations to see how long it took in seconds and nanoseconds (should show to 9 decimal...
The following data was collected on the height (inches) and weight (pounds) of women swimmers. Height...
The following data was collected on the height (inches) and weight (pounds) of women swimmers. Height Weight 68 132 64 108 62 102 65 115 66 128 Provide a regression analysis from the height and weight data. SUMMARY OUTPUT Regression Statistics Multiple R 0.9603 R Square 0.9223 Adjusted R Square 0.8963 Standard Error 4.1231 Observations 5 ANOVA df SS MS F Significance F Regression 1 605 605 35.5882 0.0094 Residual 3 51 17 Total 4 656 Coefficients Standard Error t...
The data set is height in inches and weight in pounds of random patients at the...
The data set is height in inches and weight in pounds of random patients at the Dr's office. Predict the weight of a patient that is 67 inches tall. Is it possible to predict using linear regression? Support your answer Linear regression was completed with the following results: Equation: Weight = -281.847 + 6.335*Height p-value = 0.00161 Height Weight 68 148 69 126 66 145 70 158 66 140 68 126 64 120 66 119 70 182 62 127 68...
Language: C# Create a new Console Application. Your Application should ask the user to enter their...
Language: C# Create a new Console Application. Your Application should ask the user to enter their name and their salary. Your application should calculate how much they have to pay in taxes each year and output each amount as well as their net salary (the amount they bring home after taxes are paid!). The only taxes that we will consider for this Application are Federal and FICA. Your Application needs to validate all numeric input that is entered to make...
Language C++ Ask the user to enter the name of one primary color (red, blue, yellow)...
Language C++ Ask the user to enter the name of one primary color (red, blue, yellow) and a second primary color that is different from the first. Based on the user's entries, figure out what new color will be made when mixing those two colors. Use the following guide: red and blue make purple blue and yellow make green yellow and red make orange If the user enters anything that is outside one of the above combinations, return an error...
Student What is your height in inches? What is your weight in pounds? What is your...
Student What is your height in inches? What is your weight in pounds? What is your cumulative Grade Point Average (GPA) at FTCC or your primary college? How many hours do you sleep each night? 1 67 100 4 7 2 62 105 4 5 3 72 120 4 8 4 61 125 4 7 5 56 105 3.7 6 6 61 120 4 7 7 65 172 3.8 7 8 72 235 3.22 5 9 63 135 4 6...
Student What is your height in inches? What is your weight in pounds? What is your...
Student What is your height in inches? What is your weight in pounds? What is your cumulative Grade Point Average (GPA) at FTCC or your primary college? How many hours do you sleep each night? 1 67 100 4 7 2 62 105 4 5 3 72 120 4 8 4 61 125 4 7 5 56 105 3.7 6 6 61 120 4 7 7 65 172 3.8 7 8 72 235 3.22 5 9 63 135 4 6...
1-A regression analysis between weight (y in pounds) and height (x in inches) resulted in the...
1-A regression analysis between weight (y in pounds) and height (x in inches) resulted in the following least squares line: ?̂=120+5? This implies that if the height is increased by 1 inch, the weight is expected to: A. increase by 5 pounds B. increase by 24 pounds C. increase by 1 pound D. decrease by 1 pound If the coefficient of correlation is -0.60, then the coefficient of determination is: A. 0.36 B. -0.36 C. -0.60 D. 0.40 2- For...
Write a mips assembly language program to ask the user to enter two integers A and...
Write a mips assembly language program to ask the user to enter two integers A and B and then display the result of computing the expression: A + 2B - 5.
In C# When the user enters an invalid value, ask the user to repeatedly enter the...
In C# When the user enters an invalid value, ask the user to repeatedly enter the value until a valid value has been entered. Gender must be ‘M’ or ‘F’. Residency must be ‘I’ or ‘O’. Existing Code: using System; public class Student {   public int credit;   public String firstname, lastname, gender, residency, edate;   public void input()   {     Console.WriteLine("\nWelcome to the Continental University Registration System!"); Console.WriteLine("\nEnter data about a student"); Console.Write("First Name: "); firstname = Console.ReadLine(); Console.Write("Last Name: "); lastname...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT