Prompting for grades, with confirmation if a score higher than 100 is entered This is an exercise from my computer programming class. This program reads in student scores from the user (input) and displays the total points earned along with a grade. I am tasked with modifying it to ask the user for confirmation when a score higher than 100 is entered. Plainly, it should not add a score greater than 100 to the accumulator without permission.

Here is the original source:

 //Lab7-2.cpp - displays the total points earned and grade
 //Created/revised by &lt;your name&gt; on &lt;current date&gt;

 #include &lt;iostream&gt;

 using namespace std;

 int main()
 {  
 //declare variables
    int score       = 0;
    int totalPoints = 0;  //accumulator
    char grade      = ' ';

    //get first score
    cout &lt;&lt; "First score (-1 to stop): ";
    cin &gt;&gt; score;

    while (score != -1)
    {
        //update accumulator, then get another score
        totalPoints += score;
    cout &lt;&lt; "Next score (-1 to stop): ";
    cin &gt;&gt; score;
    }   //end while

    //determine grade
    if (totalPoints &gt;= 315)
    grade = 'A';
    else if (totalPoints &gt;= 280)
    grade = 'B';
    else if (totalPoints &gt;= 245)
    grade = 'C';
    else if (totalPoints &gt;= 210)
    grade = 'D';
    else
    grade = 'F';
    //end if

    //display the total points and grade
    cout &lt;&lt; "Total points earned: " &lt;&lt; totalPoints &lt;&lt; endl;
    cout &lt;&lt; "Grade: " &lt;&lt; grade &lt;&lt; endl;

    system("pause");
 return 0;
 }   //end of main function


Here is the modified source:

//Lab7-2.cpp - displays the total points earned and grade
//Created/revised by Willy Njundong on 2/14/2016

#include &lt;iostream&gt;

using namespace std;

int main()
{
//declare variables
int score = 0;
int totalPoints = 0;  //accumulator
char grade = ' ';
char decision = ' ';

//get first score
cout &lt;&lt; "First score (-1 to stop): ";
cin &gt;&gt; score;


while (score != -1)
{
    if (score &gt; 100)                                                
    {                                                                //CONFIRM SCORE VALIDITY
        cout &lt;&lt; endl &lt;&lt; "Is score correct? (Enter y or n): ";        //IF GREATER THAN 100
        cin &gt;&gt; decision; cout &lt;&lt; endl;                              
        if (decision != 'y' &amp;&amp; decision != 'Y')                 //ANY CHARACTER ENTERED OTHER THAN 'Y' FOR YES
            score = 0;                                          //RESULTS IN SCORE OVER 100 BEING IGNORED (SET TO ZERO)
        else
        {                                                       //AND THEN THE
            //update accumulator, then get another score        //PROGRAM RESUMES NORMAL EVALUATION
            totalPoints += score;
            cout &lt;&lt; "Next score (-1 to stop): ";
            cin &gt;&gt; score;
        }   //end if

    }
    else                                                        //THESE ARE PROCESSED WHEN SCORES
    {                                                           //ENTERED ARE 100 OR LESS
        //update accumulator, then get another score
        totalPoints += score;
        cout &lt;&lt; "Next score (-1 to stop): ";
        cin &gt;&gt; score;
    }   //end if

}   //end while

    //determine grade
if (totalPoints &gt;= 315)
    grade = 'A';
else if (totalPoints &gt;= 280)
    grade = 'B';
else if (totalPoints &gt;= 245)
    grade = 'C';
else if (totalPoints &gt;= 210)
    grade = 'D';
else
    grade = 'F';
//end if



//display the total points and grade
cout &lt;&lt; "Total points earned: " &lt;&lt; totalPoints &lt;&lt; endl;
cout &lt;&lt; "Grade: " &lt;&lt; grade &lt;&lt; endl;

system("pause");
return 0;
}   //end of main function
The only option is this one:

// ...
while (score != -1) {
    if (score &gt; 100) {
        cout &lt;&lt; endl &lt;&lt; "Is the score correct? (Enter 'y' or 'n'): ";
        cin &gt;&gt; decision; cout &lt;&lt; endl;
        if (decision != 'y' &amp;&amp; decision != 'Y') score = 0;
    }

    totalPoints += score;
    cout &lt;&lt; "Next score ('-1' to stop): ";
    cin &gt;&gt; score;
}   //end while
// ...


It can't be more efficient using given circumstances.