Adjusting jacket size by age in 10-year increments

  • Topic: C/C++ 
  • Thread starter Thread starter Streitsky
  • Start date Start date
  • Tags Tags
    C++ Loop
Join the discussion
Registration is free. Start your own thread to ask a follow-up.
2 replies · 3K views
Streitsky
Messages
2
Reaction score
0
Hey guys it my first post, so please be nice :). So I am doing a problem right now and I can decide how to go about it... I am kinda lost right now, I could use an If/Else statement but it would take along time so I decided to use a loop, so here is the problem.

Program asks user to enter height weight and age. (Completed already)

Jacket size = height times weight divided by 288 and then (This is where I am having trouble>>) adjusted 1/8 of an inch for 10 years after 30 (For example adjusted 1/8 of an inch at 40, 50, 60, 70, but not at 39, 49, 59, 69) Thanks for your help
 
Physics news on Phys.org
You could solve this with a loop, but I'd just divide and round:

Code:
if (age < 40)
  adj = 0;
else
  adj = floor(age / 10 - 3) * 1.0/8;
 
hmm yea, maybe I shouldn't loop it, ill try the if else statement thanks