Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- class Student
- {
- string name,rollno,section;
- double percentageofmark;
- public:
- Student()
- {
- name="";
- rollno="";
- section="";
- percentageofmark=0.0;
- }
- Student(string nam,string rol,string sec,double mark)
- {
- this->name=nam;
- this->rollno=rol;
- this->section=sec;
- this->percentageofmark=mark;
- }
- ~Student()
- {
- //cout<<"destructor"<<endl;
- }
- void input()
- {
- cout<<"Enter Name Roll Section and Mark"<<endl;
- string nam,rol,sec;
- double mark;
- cin>>nam>>rol>>sec;
- cin>>mark;
- name=nam;
- rollno=rol;
- section=sec;
- percentageofmark=mark;
- }
- void show()
- {
- cout<<"Name: "<<this->name<<endl;
- cout<<"Roll_No:"<<this->rollno<<endl;
- cout<<"Section: "<<this->section<<endl;
- }
- void gradecalculator()
- {
- cout<<"Grade ";
- int x=this->percentageofmark;
- if(x>=90)
- {
- cout<<"A+"<<endl;
- }
- else if(x>=85)
- {
- cout<<"A"<<endl;
- }
- else if(x>=80)
- {
- cout<<"B+"<<endl;
- }
- else if(x>=75)
- {
- cout<<"B"<<endl;
- }
- else if(x>=70)
- {
- cout<<"C+"<<endl;
- }
- else if(x>=65)
- {
- cout<<"C"<<endl;
- }
- else if(x>=60)
- {
- cout<<"D+"<<endl;
- }
- else if(x>=50)
- {
- cout<<"D"<<endl;
- }
- else
- {
- cout<<"Fail"<<endl;
- }
- }
- };
- int main()
- {
- Student s1;
- s1.input();
- s1.show();
- s1.gradecalculator();
- cout<<"Second Object"<<endl;
- Student s2("shahriar","20-43565-1","b[28]",85);
- s2.show();
- s2.gradecalculator();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment