AIM:-Write a program to model student class which contains Enrollment number, Name of student, Course, Semester, Marks of subject FOP, DBMS, CFO, Maths and PC.
Input:-
#include<iostream>
#include<string.h>
using namespace std;
class student
{
int sub1,sub2,sub3,sub4,sub5,sum=0,per,er_no,num_sub=0,sem,i;
char s_name[50],course[50],grde;
public:
void accept()
{
cout<<“enter the er_no:”;
cin>>er_no;
cout<<“enter s_name:”;
cin>>s_name;
cout<<“enter course:”;
cin>>course;
cout<<“enter sem:”;
cin>>sem;
cout<<“\n rdbms:”;
cin>>sub1;
cout<<“\n cpp:”;
cin>>sub2;
cout<<“\n de:”;
cin>>sub3;
cout<<“\n maths:”;
cin>>sub4;
cout<<“\n es:”;
cin>>sub5;
sum=sub1+sub2+sub3+sub4+sub5;
}
void calculate()
{
per=sum*100/500;
cout<<“per:”<<per;
if(per>=80)
{
cout<<” o grade”;
grde=‘o’;
}
else if(per>=70 && per<80)
{
cout<<” a grade”;
grde=‘a’;
}
else if(per>=60 && per<70)
{
cout<<” b grade”;
grde=‘b’;
}
else if(per>=50 && per<60)
{
cout<<” c grade”;
grde=‘c’;
}
else
{
cout<<” d grade”;
grde=‘d’;
}
cout<<“\n”;
if(sub1<=40)
{
num_sub+=1;
}
if(sub2<=40)
{
num_sub+=1;
}
if(sub3<=40)
{
num_sub+=1;
}
if(sub4<=40)
{
num_sub+=1;
}
if(sub5<=40)
{
num_sub+=1;
}
cout<<“number of subject have mark less then 40:\n”<<num_sub;
}
void display()
{
cout<<“\n\n\n\n”;
cout<<“\n\t\t\t\t|————————————————–|”;
cout<<“\n\t\t\t\t| mscit sem-2 Result |”;
cout<<“\n\t\t\t\t| |”;
cout<<“\n\t\t\t\t|————————————————–|”;
cout<<“\n\t\t\t\t| student name:”<<s_name<<” |”;
cout<<“\n\t\t\t\t| Enrollment-number:”<<er_no<<“ |”;
cout<<“\n\t\t\t\t|————————————————–|”;
cout<<“\n\t\t\t\t| |”;
cout<<“\n\t\t\t\t| |”;
cout<< “\n\t\t\t\t| subject |”;
cout<<“\n\t\t\t\t| full name of subject”<<” marks |”;
cout<<“\n\t\t\t\t| rdbms :”<<sub1<<“ |”;
cout<<“\n\t\t\t\t| cpp :”<<sub2<<“ |”;
cout<<“\n\t\t\t\t| de :”<<sub3<<“ |”;
cout<<“\n\t\t\t\t| maths :”<<sub4<<“ |”;
cout<<“\n\t\t\t\t| es :”<<sub5<<“ |”;
cout<<“\n\t\t\t\t| ——–“<<“ |”;
cout<<“\n\t\t\t\t| total of mark :”<<sum<<” |”;
cout<<“\n\t\t\t\t|————————————————–|”;
cout<<“\n\t\t\t\t| |”;
cout<<“\n\t\t\t\t| |”;
cout<<“\n\t\t\t\t| |”;
cout<<“\n\t\t\t\t| per:”<<per<<” grde:”<<grde<<” block:”<<num_sub<<” |”;
cout<<“\n\t\t\t\t| |”;
cout<<“\n\t\t\t\t|————————————————–|\n”;
}
};
int main()
{
student std;
std.accept();
std.calculate();
std.display();
return 0;
}
Output:-
enter the er_no:18
enter s_name:dhaval
enter course:mscit
enter sem:2
rdbms:90
cpp:80
de:90
maths:89
es:90
per:87 o grade
number of subject have mark less then 40:
0
|————————————————–|
| mscit sem-2 Result |
| |
|————————————————–|
| student name:dhaval |
| Enrollment-number:18 |
|————————————————–|
| |
| |
| subject |
| full name of subject marks |
| rdbms :90 |
| cpp :80 |
| de :90 |
| maths :89 |
| es :90 |
| ——– |
| total of mark :439 |
|————————————————–|
| |
| |
| |
| per:87 grde:o block:0 |
| |
|————————————————–|
Program ended with exit code: 0
Leave a Reply