Instructions: Please read the following instructions carefully before submitting your assignment:
It should be clear that your assignment will not get any credit if:
Assignment
Problem Statement: Calculating No. of A Grades in Class
You are required to write a program which should take input from user in the form of characters A or B. Based upon user’s input you should calculate no. of A grades. You should use while loop or do/while loop for taking input and if / else condition for making decisions.Detailed Description:
The program should display like;
- After taking 10 inputs, you should display no. of A grades.
- If A grades are less than or equal to 2, you should display a message “Your class is Poor!”.
- If A grades are less than or equal to 7, you should display a message “Your class is Good!”.
- If A grades are greater than or equal to 8, you should display a message “Your class is Brilliant!”.
- The user should enter either A or B. If user has entered other than A or B, e.g. C,D,E etc. Your program should display a message like;
Sample Input and Output
Please Enter Grade of student 1 : A Please Enter Grade of student 2 : A Please Enter Grade of student 3 : B Please Enter Grade of student 4 : A Please Enter Grade of student 5 : B Please Enter Grade of student 6 : B Please Enter Grade of student 7 : A Please Enter Grade of student 8 : B Please Enter Grade of student 9 : C Please Enter ‘A’ or ‘B’ grade only! Please Enter Grade of student 9 : A Please Enter Grade of student 10 : A
Total No. of A Grades = 6
Your Class is Good!
Your Assignment solution must be uploaded/submitted on or before November 05, 2010
...............
using namespace std;
#include
#include
main()
{
int totalstudent=1;
int A =0,B=0;
char grad(1);
while (totalstudent <= 10)
{
cout"Please Enter Grade of student "totalstudent" :\n";
cin>>grad;
if (grad=='a' or grad =='A')
{
A = A+1;
totalstudent++;
}
else if (grad=='b' or grad =='B')
{
B += 1;
totalstudent++;
}
else
{
cout"\nPlease Enter 'A' or 'B' grade only! \n";
}
}
cout"Total No. of A Grades "A" :\n";
if (A <=2)
{
cout"\nYour class is Poor!\n";
}else if (A <=7)
cout"\nYour class is Good!\n";
else
{
cout"\nYour class is Brilliant!\n";
}
getche();
}
#include
#include
main()
{
int totalstudent=1;
int A =0,B=0;
char grad(1);
while (totalstudent <= 10)
{
cout"Please Enter Grade of student "totalstudent" :\n";
cin>>grad;
if (grad=='a' or grad =='A')
{
A = A+1;
totalstudent++;
}
else if (grad=='b' or grad =='B')
{
B += 1;
totalstudent++;
}
else
{
cout"\nPlease Enter 'A' or 'B' grade only! \n";
}
}
cout"Total No. of A Grades "A" :\n";
if (A <=2)
{
cout"\nYour class is Poor!\n";
}else if (A <=7)
cout"\nYour class is Good!\n";
else
{
cout"\nYour class is Brilliant!\n";
}
getche();
}
0 comments
Post a Comment