0% found this document useful (0 votes)
18 views2 pages

Student Grade Calculator Code

The document contains a C++ program that defines two classes, Student and Grade, to manage student quiz scores and grades. The Student class allows for input of the student's name, quiz scores, and calculation of total and average scores, while the Grade class extends Student to include grade display and GPA calculation based on user input. The main function demonstrates the usage of these classes by creating a Student object and a Grade object, prompting for user input, and displaying results.

Uploaded by

Arslan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views2 pages

Student Grade Calculator Code

The document contains a C++ program that defines two classes, Student and Grade, to manage student quiz scores and grades. The Student class allows for input of the student's name, quiz scores, and calculation of total and average scores, while the Grade class extends Student to include grade display and GPA calculation based on user input. The main function demonstrates the usage of these classes by creating a Student object and a Grade object, prompting for user input, and displaying results.

Uploaded by

Arslan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

#include <iostream>

using namespace std;


class Student{
string name;
float total_quiz_score,given_quizes;
public:
int total;
Student(){
name =" ";
total_quiz_score= 0 ;
given_quizes=5;
}
void getname(){
cout<<"enter your name "<<endl;
cin>>name;
}
void add_quiz(int score){
cout<<"Enter your score in the Last Quiz out off 20 = ";
cin>>total_quiz_score;
total_quiz_score=total_quiz_score+score;
}
void get_total_score(){
cout<<"total score in quizes = "<<total_quiz_score<<endl;
}
void getaverage_score(){
int average_score=total_quiz_score/given_quizes;
cout<<"Average score = "<<average_score<<endl;
}
int Total_marks(){
cout<<"enter your total marks in papers out off 60"<<endl;
cin>>total;
total=total+total_quiz_score;
cout<<total<<endl;
return total;
}

};
class Grade:public Student{
protected :
string grade;
public:
Grade(){
grade ="B+";
}
void display(){
cout<<"\ncheck your grade according to the total "<<endl;
cout<<"\n 90-100= A+"<<endl;
cout<<"\n 80-90= A"<<endl;
cout<<"\n 75-79= B+"<<endl;
cout<<"\n 70-74= B"<<endl;
cout<<"\n 60-69= C"<<endl;
cout<<"\n 50-59= D"<<endl;
cout<<"\n Less then 49= F"<<endl;
}
void setgrade(){
cout<<"enter your grade "<<endl;
cin>>grade;
}
void get_GPA(){
if(grade =="A+"||"a")
cout<<"your GPA 4";
else if(grade =="A"||"a")
cout<<"your GPA 4";
else if(grade =="B+"||"b")
cout<<"your GPA 3.7";
else if(grade =="B"||"b")
cout<<"your GPA 3";
else if(grade =="C"||"c")
cout<<"your GPA 2.8";
else if(grade =="D"||"d")
cout<<"your GPA 2";
else if (grade =="F"||"f")
cout<<"you're fail";

};

int main(){
Student b;
[Link]();
b.add_quiz(29.5);
b.get_total_score();
b.getaverage_score();
b.Total_marks();
Grade c;
[Link]();
[Link]();
c.get_GPA();
}

You might also like