#include //for the objects cin and cout #include //for the macro EXIT_SUCCESS; #include "grade.h" //for class grade using namespace std; int main() { try { const grade lowest; //defaults to F cout << "The lowest grade is " << lowest << ".\n"; cout << "Its numerical value is " << static_cast(lowest) << ".\n\n"; const grade highest {"A+"}; cout << "The highest grade is " << highest << ".\n"; cout << "Its numerical value is " << static_cast(highest) << ".\n\n"; const grade a[] { {"C"}, //Call constructor to construct a grade object. {"B+"}, {"B"}, {"B-"}, {"A"} }; const size_t n {size(a)}; //the number of elements in the array int sum {0}; for (const auto& g: a) { //g is each grade object in the array sum += g; //means sum = sum + g.operator int(); } grade average {lowest}; average += sum/n; cout << "Average grade in array is " << average << ".\n"; return EXIT_SUCCESS; } catch(invalid_argument& e) { cerr << e.what() << "\n"; return EXIT_FAILURE; } catch (range_error& e) { cerr << e.what() << "\n"; return EXIT_FAILURE; } return EXIT_SUCCESS; //Arrive here if no exceptions were thrown. }