1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
|
#include <iostream>
#include <iomanip>
using namespace std;
//FUNCTIONS
double averageGrade();
double classAverage(double labAverage, double testAverage, double projectAverage);
void getLetterGrade(double gradeAverage, char& determineGrade);
void displayGradeReport(double labAverage, double testAverage, double projectAverage, double gradeAverage, char determineGrade);
//MAIN
int main()
{
cout << fixed << setprecision(1);
//DECLARATIONS
double labAverage = 0.0;
double testAverage = 0.0;
double projectAverage = 0.0;
char determineGrade = ' ';
double gradeAverage = 0.0;
do {
//Statements
cout << "For Lab Grades" << endl;
labAverage = averageGrade();
labAverage = classAverage(labAverage, testAverage, projectAverage);
system("cls");
cout << "For Test Grades" << endl;
testAverage = averageGrade();
testAverage = classAverage(labAverage, testAverage, projectAverage);
system("cls");
cout << "For ProjectGrades " << endl;
projectAverage = averageGrade();
projectAverage = classAverage(labAverage, testAverage, projectAverage);
gradeAverage = classAverage(labAverage, testAverage, projectAverage);
//FUNCTIONS
getLetterGrade(gradeAverage, determineGrade);
displayGradeReport(labAverage, testAverage, projectAverage, gradeAverage, determineGrade);
//END STUFFS
system("pause");
system("cls");
cout << "Thanks For Stopping By!";
} while (gradeAverage != -1);
return 0;
}
//FUNCTIONS IN USE
double averageGrade()
{
double weightedAverage = 0.0;
double gradeAverageOption = 0.0;
double gradeTotal = 0.0;
int numGrades = 0;
double average = 0.0;
while (gradeAverageOption != -1)
{
cout << endl;
cout << "Please Enter The Grades Please OR PRESS (-1) TO EXIT: " << endl;
cin >> gradeAverageOption;
gradeTotal += gradeAverageOption;
numGrades++;
}
average = (gradeTotal + 1) / (numGrades - 1);
gradeTotal = (gradeTotal + average) / .5;
return average;
}
//NEXT FUNCTION
double classAverage(double labAverage, double testAverage, double projectAverage)
{
double weightedAverage = 0.0;
labAverage = labAverage * .5;
testAverage = testAverage * .4;
projectAverage = projectAverage * .1;
weightedAverage = (labAverage + testAverage + projectAverage);
return weightedAverage;
}
//NEXT FUNCTION
void getLetterGrade(double gradeAverage, char& determineGrade)
{
if (gradeAverage >= 90)
determineGrade = 'A';
else if (gradeAverage < 90 && gradeAverage >= 80)
determineGrade = 'B';
else if (gradeAverage < 80 && gradeAverage >= 70)
determineGrade = 'C';
else if (gradeAverage < 70 && gradeAverage >= 60)
determineGrade = 'D';
else if (gradeAverage < 60)
determineGrade = 'F';
}
//NEXT FUNCTION
void displayGradeReport(double labAverage, double testAverage, double projectAverage, double gradeAverage, char determineGrade)
{
system("cls");
cout << " ********************* Your MidTerm Grades Are ********************" << endl;
cout << " --------------------------------------------------------------------" << endl;
cout << "*****Your Lab average Is: " << setw(9) << labAverage << endl << endl;
cout << "****Your Test Average Is: " << setw(9) << testAverage << endl << endl;
cout << "*Your Project Average Is: " << setw(9) << projectAverage << endl << endl;
cout << "***Your Class Average Is: " << setw(9) << gradeAverage << setw(3) << determineGrade << endl << endl;
}
|