find student percentage by class with C++
#include<iostream.h>
#include<conio.h>
class Student
{
private:
char name[10];
float marks,per;
int s,m,h,e,p;
public:
void setInput()
{
cout<<"enter your name:-";
cin>>name;
cout<<"enter obtained marks of science:-";
cin>>s;
cout<<"enter obtained marks of Math:-";
cin>>m;
cout<<"enter obtained marks of hindi:-";
cin>>h;
cout<<"enter obtained marks of english:-";
cin>>e;
cout<<"enter obtained marks of physics:-";
cin>>p;
}
void calcualtePercentage() //User difine function
{
marks=s+m+h+e+p;
per=(marks)/500*100;
}
void showStdentsDetails()
{
cout<<name[10]<<endl;
cout<<"total sum of obtained marks are="<<marks<<endl;
cout<<"your percentage is="<<per<<"%"<<endl;
}
void calculateDivision()
{
if(per>80 && per<=100)
cout<<"you are topper with="<<per<<"%";
else
{
if(per>=60 && per<80)
cout<<"you are scored first division="<<per<<"%";
else if(per>=50 && per<60)
cout<<"you are scored second division="<<per<<"%";
else if(per>=40 && per<50)
cout<<"you are scored third division="<<per<<"%";
else if(per>37 && per<40)
cout<<"you are pass by grace="<<per<<"%";
else if(per>=36 && per<=37)
cout<<"jako rakhe saiyaan mar ske na koi="<<per<<"%";
else
cout<<"sorry,you are fails.please try again";
}
}
};
void main()
{
Student s1; //s1 is object of class.
clrscr();
s1.setInput();
s1.calcualtePercentage();
s1.calculateDivision();
s1.showStdentsDetails();
getch();
}
#include<conio.h>
class Student
{
private:
char name[10];
float marks,per;
int s,m,h,e,p;
public:
void setInput()
{
cout<<"enter your name:-";
cin>>name;
cout<<"enter obtained marks of science:-";
cin>>s;
cout<<"enter obtained marks of Math:-";
cin>>m;
cout<<"enter obtained marks of hindi:-";
cin>>h;
cout<<"enter obtained marks of english:-";
cin>>e;
cout<<"enter obtained marks of physics:-";
cin>>p;
}
void calcualtePercentage() //User difine function
{
marks=s+m+h+e+p;
per=(marks)/500*100;
}
void showStdentsDetails()
{
cout<<name[10]<<endl;
cout<<"total sum of obtained marks are="<<marks<<endl;
cout<<"your percentage is="<<per<<"%"<<endl;
}
void calculateDivision()
{
if(per>80 && per<=100)
cout<<"you are topper with="<<per<<"%";
else
{
if(per>=60 && per<80)
cout<<"you are scored first division="<<per<<"%";
else if(per>=50 && per<60)
cout<<"you are scored second division="<<per<<"%";
else if(per>=40 && per<50)
cout<<"you are scored third division="<<per<<"%";
else if(per>37 && per<40)
cout<<"you are pass by grace="<<per<<"%";
else if(per>=36 && per<=37)
cout<<"jako rakhe saiyaan mar ske na koi="<<per<<"%";
else
cout<<"sorry,you are fails.please try again";
}
}
};
void main()
{
Student s1; //s1 is object of class.
clrscr();
s1.setInput();
s1.calcualtePercentage();
s1.calculateDivision();
s1.showStdentsDetails();
getch();
}
Post a Comment