Ok, I have an if statement, and the user enters a value outside of the range....
say:
int sco; //Variable used for score.
if(sco< 0 || sco > 100)
{
cout<<"Error, You have to enter on the range 0-100\n";
// I want to be able to subtract the last input from the total
// without affect the other valid amounts.
// So, I was thinking in:
ave--;
scomax=-sco; // This is wrong because makes my score to zero, and
in the average variable, instead of subtract 1, subtract 2.
}
else
ave++;
scomax+=sco;
total=comax/ave; // This formula is right when is a valid input, but my negative formula is bad.
// Thank's 4 the comments.
say:
int sco; //Variable used for score.
if(sco< 0 || sco > 100)
{
cout<<"Error, You have to enter on the range 0-100\n";
// I want to be able to subtract the last input from the total
// without affect the other valid amounts.
// So, I was thinking in:
ave--;
scomax=-sco; // This is wrong because makes my score to zero, and
in the average variable, instead of subtract 1, subtract 2.
}
else
ave++;
scomax+=sco;
total=comax/ave; // This formula is right when is a valid input, but my negative formula is bad.
// Thank's 4 the comments.
Comment