#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"; grade next {lowest}; grade high {highest}; cout << "The grade now is " << next << "\n"<<"pre fix ++"<<"\n"; cout << "The next grade is " <<++next << "\n"<<"pre fix --"<<"\n"; cout << "The next lowest grade is " << --next << "\n\n"; cout << "An F + 5 is " << next + 5 << "\n"; cout << "If grade is a C and - 5 should be a : " <<(next + 6) - 5 << "\n\n"; // cout << "The grade now is " << next << "\n"; cout << "Post Fix++ " << next++ << "\n"; cout << "New Value "<< next << "\n\n"; cout << "The grade now is " << high << "\n"; cout << "Post Fix -- " << high-- <<"\n"; cout << "New Value: "<< high <<"\n\n"; if ( next < high ){ cout << next << " < " << high << "\n"; cout << "You are failing" << "\n\n"; } if (high > next) { cout << high << " > " << next << "\n"; cout << "You are passing" << "\n\n"; } if (high != next){ cout << high << " != " << next << "\n"; cout << "Grades are not the same" << "\n\n"; } grade f1 {"A"}; grade f2 {"A+"}; if (f1 <= f2){ cout << f1 << "<=" << f2 << "\n"; cout << "Grades are less than or equal" << "\n\n"; } grade v1 {"A"}; grade v2 {"C"}; if (v1 >= v2){ cout << v1 << " >= " << v2 << "\n"; cout << "grades are greater than or equal" << "\n\n"; } if (f1 == v1){ cout << f1 << " == " << v1 << "\n"; cout <<"Grades are equal to"<<"\n\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. }