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 108 109 110 111 112 113 114 115 116
|
#include <iostream>
using namespace std;
void getScores(double& test1, double& test2, double& test3, double& test4);
void findAverage(double& test1, double& test2, double& test3, double& test4, double& average);
char toLetterGrade(double average);
//NEW STUFF
void WelcomeMsg();
void GetScores2(double& test1, double& test2, double& test3, double& test4);
void FindAverage2(double& test1, double& test2, double& test3, double& test4, double& average);
int main()
{
double test1 = 0.0;
double test2 = 0.0;
double test3 = 0.0;
double test4 = 0.0;
double average = 0.0;
//cout << "This program calculates your class average." << endl << endl;
//NEW STUFF!!!!!!!!!!!!!
WelcomeMsg();
GetScores2(test1, test2, test3, test4);
FindAverage2(test1, test2, test3, test4, average);
//getScores(test1, test2, test3, test4);
//findAverage(test1, test2, test3, test4, average);
cout << "" << endl;
cout << "Calculated Average: " << endl;
cout << "==================" << endl;
cout << average << "%" << endl;
cout << "Letter Grade: " << toLetterGrade(average) << endl;
int n; cin >> n;
return 0;
}
void getScores(double& test1, double& test2, double& test3, double& test4)
{
cout << "Enter first test score: ";
cin >> test1;
cout << "Enter second test score: ";
cin >> test2;
cout << "Enter third test score: ";
cin >> test3;
cout << "Enter fourth test score: ";
cin >> test4;
}
void findAverage(double& test1, double& test2, double& test3, double& test4, double& average)
{
average = (test1 + test2 + test3 + test4) / 4;
}
char toLetterGrade(double average)
{
char courseGrade;
if (average >= 90)
{
courseGrade = 'A';
}
else if (average >= 80 && average < 90)
{
courseGrade = 'B';
}
else if (average >= 70 && average < 80)
{
courseGrade = 'C';
}
else if (average >= 60 && average < 70)
{
courseGrade = 'D';
}
else if (average < 60)
{
courseGrade = 'F';
}
return courseGrade;
}
void WelcomeMsg()
{
cout << "Welcome to class grade Program!" << endl;
cout << "to figure out your class grade please" << endl;
cout << "enter your score on each of the 4 tests \n" << endl;
}
void GetScores2(double& test1, double& test2, double& test3, double& test4)
{
cout << "What did you score on Test1? Possible pts: 80/80 Grade Weight: 20%\n" << endl;
cin >> test1;
cout << "What did you score on Test2? Possible pts: 100/100 Grade Weight: 25%\n" << endl;
cin >> test2;
cout << "What did you score on Test3? Possible pts: 100/100 Grade Weight: 25%\n" << endl;
cin >> test3;
cout << "What did you score on Test4? Possible pts: 120/120 Grade Weight: 30%\n" << endl;
cin >> test4;
}
void FindAverage2(double& test1, double& test2, double& test3, double& test4, double& average)
{
average = ((test1 + test2 + test3 + test4) / 400) * 100;
// prob could modulate the average here also so you don't return crazy decimals places..
}
|