/*--- print_grade_descr example from LA-run Final Exam Review in 3:00 pm CS 111 - Week 15 Lab presented by: Ambrose Sturgill adapted by: Sharon Tuttle last modified: 2025-12-12 ---*/ #include <cstdlib> #include <iostream> #include <string> #include <cmath> using namespace std; /*=== signature: print_grade_descr: char -> void purpose: expects a grade expressed as one of the following characters, has the SIDE-EFFECT of printing to the the screen the specified description for that grade, and returns NOTHING. grade: prints: 'A' or 'a' Excellent 'B' or 'b' Very Good 'C' or 'c' Acceptable 'T' or 't' Try Again for anything else, prints Unrecognized Grade tests: print_grade_descr('A'); prints to the screen: Excellent print_grade_descr('a'); prints to the screen: Excellent print_grade_descr('B'); prints to the screen: Very Good print_grade_descr('b'); prints to the screen: Very Good print_grade_descr('C'); prints to the screen: Acceptable print_grade_descr('c'); prints to the screen: Acceptable print_grade_descr('T'); prints to the screen: Try Again print_grade_descr('t'); prints to the screen: Try Again print_grade_descr('X'); prints to the screen: Unrecognized Grade ===*/ void print_grade_descr(char grade) { switch(grade) { case 'A': case 'a': cout << "Excellent" << endl; break; case 'B': case 'b': cout << "Very Good" << endl; break; case 'C': case 'c': cout << "Acceptable" << endl; break; case 'T': case 't': cout << "Try Again" << endl; break; default: cout << "Unrecognized Grade" << endl; } } /*--- test the function above ---*/ int main() { cout << boolalpha; cout << endl; cout << "*** Testing print_grade_descr ***" << endl; cout << endl << "SHOULD see Excellent:" << endl; print_grade_descr('A'); cout << endl << "SHOULD see Very Good:" << endl; print_grade_descr('B'); cout << endl << "SHOULD see Acceptable:" << endl; print_grade_descr('C'); cout << endl << "SHOULD see Try Again:" << endl; print_grade_descr('T'); cout << endl << "SHOULD see Unrecognized Grade:" << endl; print_grade_descr('X'); cout << endl << "SHOULD see Excellent:" << endl; print_grade_descr('a'); cout << endl << "SHOULD see Very Good:" << endl; print_grade_descr('b'); cout << endl << "SHOULD see Acceptable:" << endl; print_grade_descr('c'); cout << endl << "SHOULD see Try Again:" << endl; print_grade_descr('t'); cout << endl; return EXIT_SUCCESS; }