/******************************************************************************
name:jasdev sunner
student nummber 1451745
date started 2025 oct 22
purpose: the point of the program is to be able to fully underst&& c++ && how to code erase
this progarm also servers the purpose of being a grade calauctor so people who use this can calutacle there grade
&& be able to know there avarage in the class as well this code is also a showing to functions
and how to use them effectilvley
*******************************************************************************/
#include <iostream>
#include <cmath>
using namespace std;
void welcome()
{
cout<<"welcome to my grade caclator\n\n";
}
void classpercent(int& numclass, string course[9], int minclass, int maxclass)
{
do {
cout << "pick the classes you want to clacaute your avagerge with minumim 1 maxium 8\n";
cin >> numclass;
{ if ((numclass < minclass) || (numclass > maxclass))
cout << "invaild try agaian\n";
}
} while ((numclass < minclass) || (numclass > maxclass));
// pick percent
for (int x =1; x <= numclass; x++)
{
cout << "\n enter name for course" << x <<":";
cin >> course[x];
}
}
void pickmarks(int minclass, int maxclass, string course[9], double mark [9],int numclass, double& sum)
{
for (int x = 1; x <= numclass; x++)
{
do {
cout << "\nEnter mark for " << course[x]<<" between 0 && 100: ";
cin >> mark[x];
if ((mark[x] < 0) || (mark[x] > 100)) {
cout << "\nInvalid input. Please try again.\n";
}
} while ((mark[x] < 0) || (mark[x] > 100));
sum += mark[x];
}
}
void lettergrade(double mark [9],string grade[9],double point[9],double &totalpoint,int numclass)
{
for (int x = 1; x <= numclass; x++)
{
if (mark[x] >= 86)
{ grade[x] = "A";
point[x] = 4;
}
if ((mark[x] >= 73) && (mark[x] < 86))
{ grade[x] = "B";
point[x] = 3;
}
if ((mark[x] >= 67) && (mark[x] < 73))
{ grade[x] = "C+";
point[x] = 2.5;
}
if ((mark[x] >= 60) && (mark[x] < 67))
{ grade[x] = "C";
point[x] = 2;
}
if ((mark[x] >= 50) && (mark[x] < 60))
{ grade[x] = "C-";
point[x] = 1;
}
if (mark[x] < 50)
{ grade[x] = "F";
point[x] = 0;
}
totalpoint = totalpoint + point[x];
}
}
void corresponding(double mark [9],string grade[9],double point[9],double& totalpoint,int numclass,string course[9])
{
for (int x = 1; x <= numclass; x++)
{
cout << course[x] << ": " << "percent:" << mark[x] << "%"<< endl << "letter grade:" << grade[x] << endl << "gradepoint:" << point[x] << endl <<endl;
}
}
void calcuate(double totalpoint,int numclass,double sum,double &avagerge,double &gpa)
{
avagerge = sum / numclass;
gpa = totalpoint / numclass;
cout << "\navagrge:" << avagerge << "%";
cout << "\ngpa " << gpa;
}
void startover( char &repeatprogram,double &sum,double &totalpoint)
{
do {
cout <<"\n\n would you like to try again (y) for yes (N) for no: ";
cin >> repeatprogram;
sum = 0;
totalpoint = 0;
if ((repeatprogram !='y') && (repeatprogram !='Y') && (repeatprogram !='n') && (repeatprogram !='N'))
{
cout << "pick the right letter try agian \n";
}
} while ((repeatprogram !='y') && (repeatprogram !='Y') && (repeatprogram !='n') && (repeatprogram !='N'));
}
void goodbye()
{
cout << "thanks for trying my program";
}
int main()
{ // varibles choice
const int minclass=1, maxclass=8;
const int mingrade=0, maxgrade = 100;
int numclass;
string course[9];
double mark [9];
char repeatprogram;
double sum;
double avagerge;
double gradepoint;
double gpa;
string grade[9];
double point[9];
double totalpoint;
// iindruction
welcome();
// mark to 0
for (int x = 1; x <= 8; x++)
{
mark[x] = 0;
}
gpa = 0;
sum = 0;
totalpoint = 0;
// class opction
do {
classpercent( numclass, course, minclass, maxclass);
// user enter marks for each course
pickmarks( minclass, maxclass, course, mark, numclass, sum);
//displaying marks
lettergrade( mark,grade, point,totalpoint, numclass);
// displaying list of courses with corresponding marks
corresponding( mark, grade, point, totalpoint, numclass,course);
// calcuate avagerge and gpa
calcuate( totalpoint, numclass, sum, avagerge, gpa);
//repwat Code
startover(repeatprogram, sum, totalpoint);
}
while ((repeatprogram =='y') || (repeatprogram =='Y'));
goodbye();
return 0;
}