0

New Problem... it keeps outputting both under and over par grrrrrrrrrr
whats wrong with my if statement??!!

if (StrokeCount == 5 )
{
			cout<< "You are on Par Way To Go!!"<<endl;
			cout << endl;

}
else
if (StrokeCount < 5)
		
			{
				Par = 5%StrokeCount;
				cout <<" You are "<< Par <<" under Par" << endl;
				cout << endl;
			}
			else
                if (StrokeCount > 5 ) 
			    
					Par = StrokeCount%5;
				
				cout <<" You are "<< Par <<" over Par" << endl;	
				cout << endl;
3
Contributors
3
Replies
4
Views
11 Years
Discussion Span
Last Post by WolfPack
0

you forgot to block in the code for the last if statement.

if (StrokeCount > 5 ) 
             { 
			    
					Par = StrokeCount%5;
				
				cout <<" You are "<< Par <<" over Par" << endl;	
				cout << endl;
             }
0
if (StrokeCount == 5 )
{
			cout<< "You are on Par Way To Go!!"<<endl;
			cout << endl;

}
else
if (StrokeCount < 5)
		
			{
				Par = 5%StrokeCount;
				cout <<" You are "<< Par <<" under Par" << endl;
				cout << endl;
			}
			else
                if (StrokeCount > 5 ) 
			    {
					Par = StrokeCount%5;
				
				cout <<" You are "<< Par <<" over Par" << endl;	
				cout << endl;
}

You need the brackets. Also since you are checking above for StrokeCount == 5 and StrokeCount < 5 no need to check again for StrokeCount > 5. Just a simple else will do but I didnt change that since it works this way also. You can change it if you want.

What did I tell you about the Tabs and Spaces?It is difficult to read code like this. All the formatting is lost.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.