#include<iostream.h>
#include<conio.h>
#include<string.h>
class marksheet
{
int Science,SocialScience,maths,hindi,eng,tot,rno;
float avg;
char name[20],result[10],grade[10];
public:
void getdata();
void calculate();
void display();
};
void marksheet::getdata()
{
cout<<"Enter your roll number"<<"\n";
cin>>rno;
cout<<"Enter your name"<<"\n";
cin>>name;
cout<<"Enter Hindi mark"<<"\n";
cin>>hindi;
cout<<"Enter english mark"<<"\n";
cin>>eng;
cout<<"Enter maths mark"<<"\n";
cin>>maths;
cout<<"Enter SCIENCE mark"<<"\n";
cin>>Science;
cout<<"Enter SOCIAL SCIENCE mark"<<"\n";
cin>>SocialScience;
}
void marksheet::calculate()
{
tot=hindi+eng+maths+Science+SocialScience;
avg=tot/5;
if(hindi>=40&&eng>=40&&maths>=40&&Science>=40&&SocialScience>=40)
strcpy(result,"pass");
else
strcpy(result,"fail");
if(strcmp(result,"pass")==0)
{
if(avg>=90)
strcpy(grade,"S grade");
else if(avg<90&&avg>=80)
strcpy(grade,"A grade");
else if(avg<80&&avg>=70)
strcpy(grade,"B grade");
else if(avg<70&&avg>=60)
strcpy(grade,"C grade");
else if(avg<60&&avg>=50)
strcpy(grade,"D grade");
else
strcpy(grade,"E grade");
}
else
strcpy(grade,"F grade");
}
void marksheet::display()
{
cout<<"\nRegister Number: "<<rno<<"\n";
cout<<"Name: "<<name<<"\n";
cout<<"Hindi: "<<hindi<<"\n";
cout<<"English: "<<eng<<"\n";
cout<<"Maths: "<<maths<<"\n";
cout<<"SCIENCE: "<<Science<<"\n";
cout<<"SOCIALSCIENCE: "<<SocialScience<<"\n";
cout<<"Total: "<<tot<<"\n";
cout<<"Avarage: "<<avg<<"\n";
cout<<"Result: "<<tot<<"\n";
cout<<"Grade: "<<grade;
}
void main()
{
clrscr();
cout<<"\t\tMARK SHEET USING CLASSES AND OBJECTS\n\n";
marksheet ms;
ms.getdata();
ms.calculate();
ms.display();
getch();
}
#include<conio.h>
#include<string.h>
class marksheet
{
int Science,SocialScience,maths,hindi,eng,tot,rno;
float avg;
char name[20],result[10],grade[10];
public:
void getdata();
void calculate();
void display();
};
void marksheet::getdata()
{
cout<<"Enter your roll number"<<"\n";
cin>>rno;
cout<<"Enter your name"<<"\n";
cin>>name;
cout<<"Enter Hindi mark"<<"\n";
cin>>hindi;
cout<<"Enter english mark"<<"\n";
cin>>eng;
cout<<"Enter maths mark"<<"\n";
cin>>maths;
cout<<"Enter SCIENCE mark"<<"\n";
cin>>Science;
cout<<"Enter SOCIAL SCIENCE mark"<<"\n";
cin>>SocialScience;
}
void marksheet::calculate()
{
tot=hindi+eng+maths+Science+SocialScience;
avg=tot/5;
if(hindi>=40&&eng>=40&&maths>=40&&Science>=40&&SocialScience>=40)
strcpy(result,"pass");
else
strcpy(result,"fail");
if(strcmp(result,"pass")==0)
{
if(avg>=90)
strcpy(grade,"S grade");
else if(avg<90&&avg>=80)
strcpy(grade,"A grade");
else if(avg<80&&avg>=70)
strcpy(grade,"B grade");
else if(avg<70&&avg>=60)
strcpy(grade,"C grade");
else if(avg<60&&avg>=50)
strcpy(grade,"D grade");
else
strcpy(grade,"E grade");
}
else
strcpy(grade,"F grade");
}
void marksheet::display()
{
cout<<"\nRegister Number: "<<rno<<"\n";
cout<<"Name: "<<name<<"\n";
cout<<"Hindi: "<<hindi<<"\n";
cout<<"English: "<<eng<<"\n";
cout<<"Maths: "<<maths<<"\n";
cout<<"SCIENCE: "<<Science<<"\n";
cout<<"SOCIALSCIENCE: "<<SocialScience<<"\n";
cout<<"Total: "<<tot<<"\n";
cout<<"Avarage: "<<avg<<"\n";
cout<<"Result: "<<tot<<"\n";
cout<<"Grade: "<<grade;
}
void main()
{
clrscr();
cout<<"\t\tMARK SHEET USING CLASSES AND OBJECTS\n\n";
marksheet ms;
ms.getdata();
ms.calculate();
ms.display();
getch();
}
No comments:
Post a Comment