Do not use global variables. Write a program in which the main function asks for
ID: 3620680 • Letter: D
Question
Do not use global variables.Write a program in which the main function asks for the user’s height (measured in inches), weight and age (each an integer) and then calls 3 separate functions to compute clothing sizes according to the following formulas:
1) Hat size – the weight in pounds divided by the height in inches and then all that is multiplied by 2.9
2) Jacket size (chest in inches) – the height (in inches) times the weight is divided by 288 and then adjusted by adding 1/8 of an inch for each 10 years over age 30. (Note that the adjustment only takes place after a full 10 years. So there is no adjustment for ages 30-39, but 1/8 is added for age 40…and another 1/8 is added, if he’s at least 50, etc.)
3) Waist in inches- the weight divided by 5.7 and then adjusted by adding 1/10 of an inch for each 2 years over age 28. (Note the adjustment takes place after a full 2 years. So there is no adjustment for age 29, but 1/10 of an inch is added for age 30, etc)
Use a separate function for each of the 3 calculations. Call the functions compute_hat_size, compute_jacket_size, and compute_waist_size .
Each of these functions should be passed the appropriate values it needs (height, weight, age) and after it does the calculation, it should return the answer to the calling code which will and then print a message outputting what the answer was.
Your program should allow the user to repeat this calculation as many times as he wants.
Explanation / Answer
#include using namespace std; // compute hat size double compute_hat_size(double height, double weight) { return 2.9*(weight/height); } // compute jacket size double compute_jacket_size(double height, double weight, long age) { double base_size = (height*weight)/288.0; double age_adjustment = 0.0; if (age > 30) { age_adjustment = ((age-30)/10) * 0.125; } return base_size + age_adjustment; } // compute waist size double compute_waist_size(double height, double weight, long age) { double base_size = weight/5.7; double age_adjustment = 0.0; if (age > 28) { age_adjustment = ((age-28)/2) * 0.1; } return base_size + age_adjustment; } //repeat function bool Continue() { char decision; cout decision; return (decision=='y')||(decision=='Y'); } int main() { double height; double weight; long age; double hat_size; double jacket_size; double waist_size; coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.