/* This program is the solution to the problem discussed in the stepwise refineet set of slides. * We read in a bunch of test grades, one by one. The user can enter as many as they want, and the stop by entering -1. * Here, -1 is a "sentinel value" * The problem is to calculate the average of the test grades. */ #include using namespace std; int main() { //declare the variables required first double grade; double sum=0; int count=0; double avg; //We have to get at least one value from the user. // A do-while loop makes sense here do { cout<<"Enter the grade. (-1 to stop): "; cin>>grade; //We only need to count the entry as a grade if it is not -1 if(grade != -1) { sum = sum+ grade; count = count +1; //We need a count for the average } }while(grade != -1); //Stop if we have -1 if(count!=0) //To avoid dividing by 0 and breaking physics { avg= sum/count; cout<<"The test average is "<