(revised) First off. I am a total noob. Secondly, I can't figure out what I've done wrong with this code for calculating the amount of calories an individual needs to intake daily to maintain their weight. I don't think I did the braces thing correctly as someone attempted to explain how. I did, however change the formula needed to obtain the daily caloric intake needed.
I do believe someone is gonna have to hold my hand on this one and fix my code. OR better explain the braces for the if and else's. Also, an error message I receive is 26 [Error] 'Y' was not declared in this scope
if (toupper(sex) == 'M')
char active = ' ';
cout << "Are you moderately active? :";
cin >> active;
if (toupper(active) == Y)
calories = weight(weight * 15)
else
calories = weight(weight *13)
//end if
//end if
Your if-blocks and indentations* are wrong. Curly braces denote code blocks. If you want to execute multiple commands within an if-block, you have to wrap it in a set of curly braces { ... }.
1 2 3
if (something)
do_this();
always_do_this();
vs.
1 2 3 4 5 6
if (something)
{
do_this();
do_that();
}
always_do_this();
*indentation doesn't matter to the compiler, but it does matter to any human being in terms of readability.