Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

How to Loop this C++

  1. Feb 11, 2009 #1
    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
  2. jcsd
  3. Feb 11, 2009 #2


    User Avatar
    Science Advisor
    Homework Helper

    You could solve this with a loop, but I'd just divide and round:

    Code (Text):
    if (age < 40)
      adj = 0;
      adj = floor(age / 10 - 3) * 1.0/8;
  4. Feb 12, 2009 #3
    hmm yea, maybe I shouldnt loop it, ill try the if else statement thanks
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook