Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please solve this problem in Linux C++ Description: This program is going to all

ID: 3698772 • Letter: P

Question

please solve this problem in Linux C++

Description: This program is going to allow you to calculate your grade for the class. In your program, you will ask for the user name (it should be able to include spaces). You will then ask for grades for homework assignments and have the user enter -1 when they have entered all of the grades. Next, you will ask the user for programming grades and again have them enter -1 when all are entered. You will ask for the quiz grades or -1 to end. You will ask for the exam grades or 1 to end. You will read the values into an array so that you can pass them to a function (the function is defined below). Consider: Do you need more than one array? You will calculate the grade percentage as follows: if homework grades sum the homework grades divide the sum of the homework grades by the number of homework grades entered multiple the result by 10 Add the result to the overall score

Explanation / Answer


Given below is the code for the question.
Please do rate the answer if it was helpful. Thank you

#include <iostream>
#include <cctype>
using namespace std;
void inputGrades(string type, double grades[], int &n);
double calculateGradePerc(double grades[], int n, int multiplier);
string calculateLetterGrade(double grade);
int countBelow60(double grades[], int n);
string toUpperCase(string name);
int main()
{
double grades[10];
int n;
double overallScore = 0;
string letterGrade;
string name;
cout << "Enter name: ";
getline(cin, name);
inputGrades("homework", grades, n);
overallScore += calculateGradePerc(grades, n, 10);
int progMultiplier = 50;
if(n > 0) //if there are homework grades, multiplier is 40
progMultiplier = 40;
inputGrades("program", grades, n);
overallScore += calculateGradePerc(grades, n, progMultiplier);
inputGrades("quiz", grades, n);
overallScore += calculateGradePerc(grades, n, 10);
inputGrades("exam", grades, n);
overallScore += calculateGradePerc(grades, n, 40);
if(countBelow60(grades, n) > 2)
letterGrade = "F";
else
letterGrade = calculateLetterGrade(overallScore);
name = toUpperCase(name);
cout << "Results: " << name << " " << overallScore << " " << letterGrade << endl;
}

void inputGrades(string type, double grades[], int &n)
{
double score;
n = 0;
cout << endl << endl;
while(true)
{
cout << "Enter " << type << " grade (enter -1 when done): ";
cin >> score;
if(score == -1)
break;
grades[n++] = score;
}
}
double calculateGradePerc(double grades[], int n, int multiplier)
{
double sum = 0;
double avg = 0;
for(int i = 0; i < n; i++)
sum += grades[i];
if(n != 0)
avg = (sum / n) / 100.0; //avg percentage
avg *= multiplier;
return avg;
}
string calculateLetterGrade(double grade)
{
if(grade >= 93)
return "A";
else if(grade >= 90)
return "A-";
else if(grade >= 85)
return "B+";
else if(grade >= 82)
return "B";
else if(grade >= 80)
return "B-";
else if(grade >= 76)
return "C+";
else if(grade >= 72)
return "C";
else if(grade >= 69.5)
return "C-";
else if(grade >= 68)
return "D+";
else if(grade >= 65)
return "D";
else if(grade >= 60)
return "D-";
else
return "F";
}
int countBelow60(double grades[], int n)
{
int count = 0;
for(int i = 0; i < n; i++)
{
if(grades[i] < 60)
count++;
}
return count;
}
string toUpperCase(string name)
{
string s = "";
for(int i = 0; i < name.length(); i++)
s += toupper(name[i]);
return s;
}


output
Enter name: Santa Claus

Enter homework grade (enter -1 when done): 70
Enter homework grade (enter -1 when done): 80
Enter homework grade (enter -1 when done): -1

Enter program grade (enter -1 when done): 86
Enter program grade (enter -1 when done): 89
Enter program grade (enter -1 when done): 90
Enter program grade (enter -1 when done): -1

Enter quiz grade (enter -1 when done): 88
Enter quiz grade (enter -1 when done): 90
Enter quiz grade (enter -1 when done): -1

Enter exam grade (enter -1 when done): 70
Enter exam grade (enter -1 when done): 80
Enter exam grade (enter -1 when done): -1
Results: SANTA CLAUS 81.7333 B-