/*PROGRAM TO ENTER NAME, ROLLNO, MARKS IN FIVE SUBJECTS, TOTAL, PERCENTAGE AND GRADE (USING SWITCH CASE) */
#include<iostream.h>
#include<conio.h>
class grade
{
int r,g,t,i,total,m[5];
char a[15];
float per;
public:
void process();
};
void grade::process()
{
total=0;
cout<<“Enter the name of the student: “;
cin>>a;
cout<<“Enter the roll number of the student: “;
cin>>r;
cout<<“Enter marks obtained in five subjects: “<<endl;
for(i=0;i<5;i++)
{
cout<<“Enter marks in”<<i+1<<” subject: “;
cin>>t;
if(t<=100)
m[i]=t;
else
{
cout<<“Marks should not exceed 100\n”;
i=i-1;
}
}
for(i=0;i<5;i++)
total=total+m[i];
per=(total/500.0)*100;
cout<<“\nNAME\tROLLNO\tTOTAL\tPERCENTAGE\tGRADE\n\n” ;
cout<<a<<“\t”<<r<<“\t”<<total<<“\t”<<per<<“\t”;
g=per/10;
switch(g)
{
case 9:
case 8:
case 7:
cout<<“Grade A”;
break;
case 6:
case 5:
cout<<“Grade B”;
break;
case 4:
cout<<“Grade C”;
break;
default:
cout<<“Grade D”;
}
}
void main()
{
grade g1;
clrscr();
g1.process();
getch();
}