I'm having trouble figuring out how to write the math for part of the function below. How would I account for the 1/8 inch adjustment for every 10 years over age 30?
Problem: Write a program that asks for the user’s height, weight, and age, and then computes clothing sizes according to the formulas:
• Jacket size (chest in inches) = height times weight 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 through 39, but 1/8 of an inch is added for age 40.)
***This was my attempt so far at writing a function for jacket size.
That's a pretty decent start. You will also need to accept the age in your function argument list. Then you can do something like the following:
1 2 3 4 5 6 7 8
constexprdouble inch_multiplier = 1.0/8; //1/8th of an inch will be the multiplier
if (age >= 40)
age -= 30; //don't account for first 30 years
int full_decades = age/10; //calculate amount of decades
jacketsize += full_decades*inch_multiplier; //multiply decades by 1/8th of an inch
Hope that helps, please do let us know if you require any further help.