11-07-2010, 05:10 AM
Sorry for late solution please compile it.
Code:
#include <iostream.h>
main()
{
//declaration of variables and intialization
char grade;
int counter = 1; //loop counter
int counterA = 0; // counter for number of grade A
do
{
//prompt user to enter grade
cout<< "Please Enter Grade of student " << counter<< endl;
cin>> grade;
if (grade == 'A' || grade == 'a') //check whether A was entered
counterA = counterA + 1; //increment A counter by 1
counter = counter + 1; //increment loop counter by 1
else if (grade == 'B' || grade == 'b') //check whether B was entered
counter = counter + 1; // increment loop counter by 1
else
cout << "Please Enter 'A' or 'B' grade only" << endl; //handle invalid grades
}
while (counter <= 10);//taking ten grades from user
cout << "Total No. of A Grades = " << counterA << endl; // display results
if (counterA <= 2) //check no of A for declaraing result
cout << "Your class is Poor!" << endl;
else if (counterA > 2 && counterA <= 7)//check no of A for declaraing result
cout << "Your class is Good!" << endl;
else
cout << "Your class is Brilliant!" << endl;
}