Question: Program in C++ (1) Basal Metabolic Rate (from the Savitch Ch 2 Programming Projects) The Harris-Benedict equation estimates the number of calories your body needs
Program in C++
(1) Basal Metabolic Rate (from the Savitch Ch 2 Programming Projects)
The Harris-Benedict equation estimates the number of calories your body needs to main- tain your weight if you do no exercise whatsoever. This is called your basal metabolic rate, or BMR (note this is a single variable name, not three variables multiplied together). The formula for the calories needed for a woman to maintain her weight is :
BMR = 655 + (4.3 weight in pounds) + (4.7 height in inches) (4.7 age in years).
The formula for the calories needed for a man to maintain his weight is
:BMR = 66 + (6.3 weight in pounds) + (12.9 height in inches) (6.8 age in years).
A typical chocolate bar contains approximately 230 calories. Write a program that allows the user to input his or her weight in pounds, height in inches, age in years, and the character M for male or F for female. The program should then output the number of 230 calorie chocolate bars that need to be consumed to maintain ones weight for a person of the input sex, height, weight, and age.
(2) Temperature Conversion
For weather reporting, the daily temperature will generally be given in degrees Celsius or Fahrenheit. Write a C++ program that will convert a temperature given in one system of units to the other. For example, if the temperature is given in degrees Fahrenheit convert it to Celsius, and vice versa.
Your program should prompt the user to provide a temperature value (object type double) and a single character (f or c) to indicate if the value is in degrees Fahrenheit or Celsius. Read in the temperature and scale values, then compute and display the corresponding equivalent temperature in the other scale system. Your output message should indicate whether the result is Celsius or Fahrenheit.
For example: Example 1 (underlined values are user inputs):
Enter the temperature: 26.6
Enter Celsius (c) or Fahrenheit (f): c
The temperature in Fahrenheit is 79.88
Example 2 (underlined values are user inputs):
Enter the temperature: 93.2
Enter Celsius (c) or Fahrenheit (f): f
The temperature in Celsius is 34
Use the following conversion formulas: F = C (9/5) + 32 C = (F 32) (5/9)
[Hint: remember there is a difference between division of integers and division of doubles. Be careful when translating the equations above into C++.]
Test your program using the following values, as well as some other test cases you and your partner think up:
(i) convert 37 degrees Celsius to Fahrenheit;
(ii) convert 98.6 Fahrenheit to Celsius;
(iii) convert 32 Fahrenheit to Celsius;
(iv) convert -40 Fahrenheit to Celsius.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
