0

Hey, I am having problems with the double waistsize function, I am not sure where I have gone wrong..I am not getting the outputs I should be.

waistsize should be user_weight divided by 5.7...adding 1/10 of an inch for each 2 years over age 28, so when it is 30 1/10 of an inch should be added, but nothing should be added when its 29.

```
#include "stdafx.h"
#include <iostream>
using namespace std;
double hatsize(double user_weight, double user_height); // hat size function declaration
double waistsize(double user_weight, int user_age); //waist size function declaration
int _tmain(int argc, _TCHAR* argv[])
{
double user_height;
double user_weight;
int user_age;
//char ans; // answer for do while loop. *repeat the program
double hat; // hat size result
double waist; // waist size result
// User details entry
cout << "Computing Clothing Sizes\n";
cout << "________________________\n";
cout << "Please enter your height in inches:\n";
cin >> user_height;
cout << "Please enter your weight in pounds:\n";
cin >> user_weight;
cout << "\n";
cout << "Please enter your age:\n";
cin >> user_age;
cout << endl;
hat = hatsize(user_weight, user_height); // hat size function call
cout << "Your hat size is: ";
cout << hat;
cout << endl;
waist = waistsize(user_weight, user_age); // waist size function call
cout << "Your waist size is: ";
cout << waist;
cout << endl;
return 0;
}
//Hat size Formula
double hatsize(double user_weight, double user_height) // hatsize function heading
{
return (user_weight / user_height * 2.9);
}
double waistsize (double user_weight, int user_age) // waist size function heading
{
int tempage; // is it even?
double weightcalc;
tempage = user_age;
if (user_age >= 30) // nested if statements...
{
//do {
if (user_age % 2 == 0) // if the age is even
{
tempage = tempage / 2.0; // number of twos...
tempage = tempage * 0.1;//...used for calculating number of times to add 1/10 of an inch
}
if (user_age % 2 != 0)
{
tempage = tempage - 1.0; // if it wasnt an even number 1 will be taken away to make it even
tempage = tempage / 2.0; // number of twos...
tempage = tempage * 0.1;//...used for calculating number of times to add 1/10 of an inch
}
//} while (user_age % 2 != 0); // while the remainder is greater then 0 it will loop.
}
//The weight calculation
weightcalc = user_weight / 5.7;
return (weightcalc + tempage);
}
//waistcalculation = user_weight / 5.7;
// if age is not even then...
// round down so that if number / number = 0
//example 5%3 returns the value of 2, because 2 is the remainder after dividing 5 by 3
//do
//{
//if (user_age >= 30)
//{
//waistcalculation = waistcalculation + 0.1; // add 1/10 to waist
//count = count + 2;
//}
//}while (count < user_age);
//
//return (waistcalculation);
//}
```