In my last excercise I have an IF/Else statement & a second pass counter, here is the code:
How can I remove the second pass counter (++pass) & the duplicate line of code? I just need a very simple solution. Thanks.
Code:
//Students are allowed to fail one exam, not both, this is how we achieve that goal.
if ((midterm < EXAMSPASS && final < EXAMSPASS) || course < PASSMARK)
{
fail++;
cout << endl << "RESULT: " << name << " " << "Failed " << endl;
cout << "-------------------------------------------" << endl;
}
else if (course >= HONOURS)
{
pass++;
cout << endl << "RESULT: " << name << " " << "Passed with Honours "
<< endl;
cout << "-------------------------------------------" << endl;
}
else
{
//Since pass+1 is set above, need to reset the counter this way
//so it counts the passed results correctly
++pass;
cout << endl << "RESULT: " << name << " " << "Passed " << endl;
cout << "-------------------------------------------" << endl;
}