Question: Lab 8 C++ Define an enumeration data type called grades, containing F, D, C, B, and A. Declare a variable of this data type with

Lab 8

C++

Define an enumeration data type called grades, containing F, D, C, B, and A. Declare a variable of this data type with your name, that is,

grades FirstName_LastName;

Initialize this variable with a value of F.

Then, write a function containing:

1. A loop that increments the value stored in your grade variable (using static_cast;) until you reach your desired grade.

2. A local char variable called myGrade to be returned by the function.

3. A conditional block that stores the grade as a character in myGrade (as in slide 14 of Chapter 7; set myGrade to this value instead of using cout).

This function should take as input a grade variable (your name), and return type char (your desired grade).

(For extra credit, try overloading the addition operator and avoid static casting if possible. Maybe make a new class for which this overloaded operator is defined. Whatever you can come up with that is creative. Up to 5 points.)

Output the value of this function to the screen.

It should say FirstName LastNames grade: (your function output)

Note: This was originally intended for CSC 1101 students. As CSC 2110/2111 students, your only requirement as written in here is:

enum grades{F, D, C, B, A};

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!