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;

Recommended Answers

All 3 Replies

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;
             }

It's always something simple isnt it!!! thanx!

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.