Student Grade Calculator Using C++ Only
Student Grade Calculator Using C++ Only
University of Haripur
Submitted to
Muhammad Bilal
Submitted by
F23-0517-IT-BS(SE)/UOH
Assignment #02
Fall, 2024
Description
I created a GPA calculator that calculates GPA based on specific conditions using if-else-if and
switch statements. The user is prompted to enter their name and the marks they receive in each
subject. The program includes the subjects from my second semester. It computes the average
of the marks, and using that average, it determines the GPA through if-else-if statements.
Finally, the program provides feedback based on the GPA obtained by the user using a switch
statement. Additionally, I used a transform function to convert the username to uppercase. The
program turned out to be well and its accuracy and precision are greater than 90%.
Source Code
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <cctype>
string student_Name;
float natural_science, arts_humanities, functional_english, social_science,
quantitative_reasoning, islamic_studies;
2
//student name
//Entering Marks
transform(student_Name.begin(), student_Name.end(),
student_Name.begin(),::toupper);
3
cout << "\nQuantitative Reasoning = " << quantitative_reasoning;
cout << "\nIslamic Studies = " << islamic_studies;
//Calculating Average
float gpa;
4
else if(average >= 60 && average <= 64)
{
gpa = 2.8;
}
else
{
cout << "\nInvalid Input.";
}
//gpa output
5
int gpa_int = gpa *10;
string feedback;
switch (gpa_int)
{
case 40:
feedback = "Excellent Work (A+)";
break;
case 39:
case 38:
case 37:
case 36:
case 35:
feedback = "Very Good (A-)";
break;
case 34:
case 33:
case 32:
case 31:
case 30:
feedback = "Good (B)";
break;
case 29:
case 28:
case 27:
case 26:
case 25:
feedback = "Fair (C)";
break;
case 24:
case 23:
case 22:
case 21:
case 20:
feedback = "Pass (D)";
break;
default:
6
feedback = "Fail (F)";
break;
}
//feedback output
return 0;
}
Output
----------Welcome to Grade Calculator----------
Marks :
Natural Science = 78
Arts & Humanities = 91
Functional English = 85
Social Science = 89
Quantitative Reasoning = 92
Islamic Studies = 91
Average = 88
GPA = 3.8
Feedback = Very Good (A-)
The End