#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
class student
{ private: int rollno;
char name[30];
int marks3[3];
float avg;
float calcgrade(float avg);
char grade;
public: student()
{
}
student(int rollno, char name, int marks){};
void accp();
void disp();
~student(){};
};
void main()
{ clrscr();
student s;
s.accp();
s.disp();
getch();
}
void student::accp()
{ avg=0;
cout<<"\n enter the roll number:";
cin>>rollno;
cout<<"\n enter the name:";
gets(name);
for(int i=0; i<3; i++)
{ cout<<"\n enter the subject marks:";
cin>>marks3[i];
}
for(i=0; i<3; i++)
{ avg=avg+marks3[i];
}
avg=avg/3;
grade=calcgrade(avg);
}
float student::calcgrade(float avg)
{ char grd;
if(avg>=90)
grd='A';
else
if(avg<90 && avg>=70)
grd='B';
else
grd='C';
return grd;
}
void student::disp()
{ cout<<"\n roll number:"<<rollno;
cout<<"\n name is:"<<name;
for(int i=0; i<3; i++)
{ cout<<"\n marks is "<<marks3[i];
}
cout<<"\n average is "<<avg;
cout<<"\n grade is "<<grade;
}
0 comments:
Post a Comment