#include #include #include #define NUMTESTS 3 using namespace std; /**************************/ /* Function Prototypes */ /**************************/ // Get the student's SSN string getSSN(); // Get each test score --> call 3 different times float getTestScore(string testNum); // Calculate the average of the three test scores float calcAvg(float score1, float score2, float score3); // Print student's SSN and test average void printStuInfo(string ssn, float testAvg); int main() { float test1, test2, test3; float avg; string ssn; ssn = getSSN(); test1 = getTestScore("one"); test2 = getTestScore("two"); test3 = getTestScore("three"); avg = calcAvg(test1, test2, test3); printStuInfo(ssn, avg); return 0; } // end main // Function name: getSSN // Description: get student's SSN // Parameters: none // Return value: the student's SSN string getSSN() { string socialNum; cout << "Enter student's SSN: "; cin >> socialNum; return socialNum; } // end function getSSN float getTestScore(string testNum) { float score; cout << "Enter test score number " << testNum << " for a student: "; cin >> score; if (score < 0) { cout << "Test score must be >= 0!" << endl << endl; exit (0); } // end if score < 0 return score; } // end function getTestScore float calcAvg(float score1, float score2, float score3) { float sum; float ave; sum = score1 + score2 + score3; ave = sum / NUMTESTS; return ave; } // end function calcAvg void printStuInfo(string ssn, float testAvg) { cout << fixed << showpoint << setprecision(2); cout << endl << endl; cout << "Test average for " << ssn << " is " << testAvg << endl << endl; return; } // end function printStuInfo