Question

Y F G Prompt and Store. 5. Prompt the user with Enter your weight in pounds: message and store in the weight variable. 6. I

Homework Assignment 1 Directions: In the terminal on Google Cloud Shell navigate into your cs 151/Homework directory. Use the

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

CODE

#include <iostream>

#include <cmath>

using namespace std;

int main()

{

   string firstName, lastName;

   cout << "Enter your first name: ";

   cin >> firstName;

   cout << "Enter your last name: ";

   cin >> lastName;

   int age, feetOfHeight, inchesOfHeight;

   cout << "Enter your age: ";

   cin >> age;

   cout << "Enter your height in feet and inches (separated by space): ";

   cin >> feetOfHeight >> inchesOfHeight;

   double weight;

   cout << "Enter your weight in pounds: ";

   cin >> weight;

   int heightInInches = feetOfHeight * 12 + inchesOfHeight;

   double BMI = (weight * 703.0) / pow(heightInInches, 2);

   double ratio = pow(heightInInches, 2) / 703.0;

   double lowerNormal = 18.5 * ratio;

   double upperNormal = 24.9 * ratio;

   double lowerOverweight = 25 * ratio;

   double upperOverweight = 29.9 * ratio;

   double lowerObese = 30 * ratio;

   double upperObese = 39.9 * ratio;

   cout << endl << "Candidate: " << lastName << ", " << firstName << endl;

   cout << "Height: " << heightInInches << " in" << endl;

   cout << "Weight: " << weight << " lb" << endl;

   cout << "BMI: " << BMI << endl;

   cout << "For height " << heightInInches << " in, the weight ranges are: " << endl;

   cout << "Normal weight range:  is from " << lowerNormal << " lb to " << upperNormal << " lb" << endl;

}

Add a comment
Know the answer?
Add Answer to:
Y F G Prompt and Store. 5. Prompt the user with "Enter your weight in pounds:...
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
  • 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),...

  • Write a basic C++ program that will calculate a subject’s basal metabolic rate and estimate how...

    Write a basic C++ program that will calculate a subject’s basal metabolic rate and estimate how many days it will take to lose a specific number of pounds. The program will perform the following tasks: Declare variables and Named constants. Display “Welcome to <your name>’s Weight Loss Calculator” Prompt the user to enter the subject’s current weight. Prompt the user to enter the subject’s height in feet plus inches. Prompt the user to enter the subject’s age. Prompt the user...

  • /////////////////////////////////////////////////////////////////////////////////// //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...

  • - A pseudo code that prompts the user for the grades of four exams and prints...

    - A pseudo code that prompts the user for the grades of four exams and prints its average and then code in JAVA - A pseudo code that prompts the user for value in meters and converts it to feet and inches. Print both results.  and then code in JAVA -A pseudo code that will calculate the users Body Mass Index (BMI) and then display it for the user to see. Prompt the user to input their weight (in pounds) and...

  • Write a program that will compute the user annual salary. Prompt the user the enter (1)...

    Write a program that will compute the user annual salary. Prompt the user the enter (1) the weekly salary. Store the information in a double variable. Prompt the user to enter the number of weeks worked in a year. Use an int variable for that. Write code that will compute the user's Annual salary. Gross salary is salary before any deductions are taken. Update the code and prompt the user to enter the federal tax rate and the state's tax...

  • 1. Your Body Mass Index (BMI) is a measure of your weight relative to your height....

    1. Your Body Mass Index (BMI) is a measure of your weight relative to your height. The formula can be found here: http://www.whathealth.com/bmi/formula.html (use the Imperial U.S. Method). Write an algorithm in pseudocode to calculate and display a person's BMI accepting as input their height in feet and inches and their weight in pounds. The output of your algorithm should be as follows: a. BMI b. A statement of whether the result is underweight, normal, overweight or obese.

  • Write a perl script to accomplish following tasks: 1. Prompt user to enter their name and...

    Write a perl script to accomplish following tasks: 1. Prompt user to enter their name and age, and then calculate and display their age in days. 2. Initialize a 20-element array of numbers and print each element. 3. Get a system host name. 4. Get a web page and save it to a file. 5. List background services (daemons) on your system.

  • 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...

  • Menu-driven programs will display the menu options to the user and then prompt them for a...

    Menu-driven programs will display the menu options to the user and then prompt them for a menu choice. This program will display the following menu in the following format: Calculator Options: Calculate the area of a circle Calculate the area of a rectangle Calculate the area of a triangle Calculate the area of a trapezoid Calculate the area of a sphere Exit Enter your choice (1-6) Once the user enters a choice for the menu, the program should use a...

  • 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...

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