C++ Program to display the result of students with
computed grade of marks with the help of a Class and manipulation of
member function.
#include<iostream.h>
#include<conio.h>
#include<string.h>
#include<dos.h>
class result // Declaration of the Class
{
private:
int serialno;
int rollnum;
int total;
int percent;
public:
void inputdata(int ser,int rol,int tot,int per)
{
serialno = ser;
rollnum = rol;
total = tot;
percent = per;
}
void display(void)
{
clrscr();
gotoxy(30,5);
cout<<"R E S U L T ";
cout<<endl;
// Music creation through sound command
for(double d=0;d<=800;d++)
{sound (d);
delay(5); }
nosound();
// Sound command de-activated
char grade[20];
cout<<endl<<"The serial number is "<<serialno;
cout<<endl<<"The roll number is "<<rollnum;
cout<<endl<<"The total marks is "<<total;
cout<<endl<<"The percent marks is "<<percent;
if (percent<40) strcpy(grade,"Fail");
if (percent>=40 && percent<60) strcpy(grade,"Pass");
if (percent>=60 && percent<80) strcpy(grade,"First");
if (percent>=80) strcpy(grade,"Excellent");
cout<<endl<<"The grade obtained is "<<grade;
cout<<endl;
}
};
main()
{
result studrecord;
int ser;
int rol;
int tot;
int per;
clrscr();
cout<<"Enter the serial number"<<endl;
cin>>ser;
cout<<"Enter the rollnumber"<<endl;
cin>>rol;
cout<<"Enter the total"<<endl;
cin>>tot;
per=tot/5;
clrscr();
studrecord.inputdata(ser,rol,tot,per);
studrecord.display();
cout<<endl;
cout<<"Press any key to return ";
getch();
clrscr();// Screen cleared for the next program output.
return 0;
}
Related Posts : C++ Programs
0 comments:
Post a Comment