do
{
// Prompt user for a grade and get input.
if(grade < -1 || grade >= 100)
{
// Optional: Display an error (eg. cout << "invalid grade" << endl;)
continue;// This will make the computer go back to the beginning of the loop and re-prompt the user for a grade.
}
if(grade != -1)
{
sum += grade;
counter++;
}
} while(grade != -1)