If age is > or = 40:
add 1/8 on jacket size for every 10th year starting from 40.
IE:
if you are 40:
jacketSize = ((1/8 )+jacketSize)*jacketSize
if you are 50:
(add another 1/8 of jacketSize to jacketSize)
jacketSize = (((1/8 )*2)+jacketSize)*jacketSize
etc... for every 10th year.
Simple when doing it on paper or in your head but when using C++...
I tried using a simple shortcut with the switch statement with formula above but the teacher wants no shortcuts and it has to work with any age. Even if it is a 50,000,000,000,000 year old man/women. He will specifically test mine if it works with an insanely old women.
I've been known to take shortcuts.
Question:
Let me re-iterate that it's easy on paper but a little more complicated in C++. I'm still thinking. If anyone can drop me a hint or 2 I would be grateful.
So far (I think it's right):
add 1/8 on jacket size for every 10th year starting from 40.
IE:
if you are 40:
jacketSize = ((1/8 )+jacketSize)*jacketSize
if you are 50:
(add another 1/8 of jacketSize to jacketSize)
jacketSize = (((1/8 )*2)+jacketSize)*jacketSize
etc... for every 10th year.
Simple when doing it on paper or in your head but when using C++...
I tried using a simple shortcut with the switch statement with formula above but the teacher wants no shortcuts and it has to work with any age. Even if it is a 50,000,000,000,000 year old man/women. He will specifically test mine if it works with an insanely old women.
I've been known to take shortcuts.
Question:
Jacket size = (height * weight) / 288 then adjusted by adding 1/8 of an inch for each 10 years over age 30. The adjustments only take place after a full 10 years. So there is no adjustment for ages 30-39 but 1/8 of an inch is added for age 40.
Let me re-iterate that it's easy on paper but a little more complicated in C++. I'm still thinking. If anyone can drop me a hint or 2 I would be grateful.
So far (I think it's right):
Code:
jacketSize = (weight*height)/288.0;
if(age >= 40)
{
while(age > 0)
{
jacketSizeTemp = age-10;
count++;
}
}
jacketSize += (age/10)*((1/8)*count);