Need Some Help Writing A Function ..

This is a discussion on Need Some Help Writing A Function .. within the C++ Programming forums, part of the General Programming Boards category; " Waist in inches = weight divided by 5.7 and then adjusted by adding 1/10 of an inch for each ...

  1. #1
    Registered User
    Join Date
    May 2007
    Posts
    14

    Need Some Help Writing A Function ..

    " Waist in inches = weight divided by 5.7 and then adjusted by adding 1/10 of an inch for each 2 years over age 28. (Note that the adjustment only takes place after a full 2 years. So, there is no adjustment for age 29, but 1/10th of an inch is added for 30.) "

    Code:
    double waistsize (int weight, int age) //Waist size Function
    {       
           using namespace std;
           
           double waistsize, adj;
           
           if (age >= 30) 
           {
           adj = (age - 28) / 2 * 0.1; // FIX
           }
           waistsize = weight / 5.7 + adj ;
           
           return (waistsize);
    }

  2. #2
    Registered User
    Join Date
    May 2007
    Posts
    14
    I'm not too sure If I am getting the adjustment part right. For Some reason, calculations arent coming out correct.

  3. #3
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Example of bad calculations?

    The code looks fine. Did you write it?

  4. #4
    Registered User
    Join Date
    May 2007
    Posts
    14
    Yes I wrote it. Though I found out what was wrong.. the outputs from my function were rounding up . Ex// waistsize would show up as 36, NOT 35.5 .
    thanks for the reply though!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  2. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 06:54 PM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 04:45 PM
  4. const at the end of a sub routine?
    By Kleid-0 in forum C++ Programming
    Replies: 14
    Last Post: 10-23-2005, 06:44 PM
  5. Replies: 3
    Last Post: 03-04-2005, 01:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21