Introduction

The aim of this take-home exam is to practice on the basics of C++ (input, output, assignment, if-else, etc.) and decision making (conditional if statements). The use of if statements is due to the nature of the problem; that is, you cannot finish this take-home exam without using decision making.

Description

After the Coronavirus affected the whole world, the grading system of Schrute University, like many universities, has changed. At Schrute University, unlike other universities, the letter grades students can receive are restricted to A, B, C, D, F, U (Unsatisfactory), and S (Satisfactory). After the final letter grades for undergraduate courses At Schrute University are determined, students are allowed to select one of the options as follows:

If the final grade is "D" or above, the student can choose to be graded with an S grade

If the final grade is "F":

  • For courses that are taken for the first time in the Fall 2020 semester:
    • The student can either select "F" or U as the final grade.
  • For courses that are repeated in the Fall 2020 semester:
    • If the previous grade is "F", the student will not be allowed to choose the U grading option as the final grade in Fall 2020. Thus, students can only choose F.
    • If the previous grade is one of "A", B, C, "D, or U, the student may choose U as the final grade.
    • If the previous grade is "S", the student cannot choose U. Thus, students can only choose F.

If students have received a "U" previous semester, they may choose S if the student currently got one of A, B, C, D. Also, a student may choose U if and only if the student currently got an F.

If students have received an "S" previous semester, they may choose S if the student's current letter grade is one of A, B, C, D, if the students current grade is F, a student may only choose F.

Under no circumstances, the student cannot choose a higher or lower grade than the letter grade he/she has received (such as choosing B while receiving C or vice-versa).

In this take-home exam, you will implement a C++ program that calculates the course grade of a Schrute University. The inputs to your program will be:

1. Name of the student,
2. Name of the course,
3. Whether she/he took the lesson for the first time, and
4. Current or previous term grade if available (if (3) is valid).
5. Finally, the letter grade the student wants to get.

After the inputs are received, the program will allow the student to get the grade he/she wants but if the grade he/she wants to get is valid within the framework of the above-given conditions. Otherwise, the program terminates the program by stating the reason why the student could not get the desired grade as an error message.

You may implement your algorithm all in the main function, i.e. you are not expected to write any user-defined functions, but of course, you can write some, if you prefer to do so.

Inputs, Flow of the Program and Outputs

The inputs of the program and their order are explained below. It is extremely important to follow this order with the same characters since we automatically process your programs. Thus, your work will be graded as 0 unless the order is entirely correct. Please see the "Sample Runs" section for some examples.

The prompts of the input statements to be used have to be exactly the same as the prompts of the "Sample Runs".

At the beginning of your program, the user will be prompted to enter his/her name as the first input. The name of the user should be displayed whenever appropriate in the prompts and the output text. Please see the "Sample Runs" section for some examples.

After the user enters his/her name, (s)he will be asked to provide his/her processed course name. The name of the course should be displayed whenever appropriate in the prompts and the output text. Please see the "Sample Runs" section for some examples.

After the user enters his/her course name, (s)he will be asked if the student has already taken the course they want to process. The user's answer to this question can be "YES" or "NO" only. If there is an answer other than these, the program will give the necessary error message and close the program. Please see the "Sample Runs" section for some examples.

If the student's answer is YES, the program will ask for the grade the student has received from the course currently processed and the student will choose from those grades (A, B, C, D, F). After that, if the student has chosen one of the passing grades (A, B, C, D), the program will ask if the student wants to convert that grade to S. If the student got an F, the program will ask if the student wants to change the grade to U. In both cases, if the student gives an invalid answer other than (A, B, C, D, F) or response other than (YES, NO), the program will display the required error message and terminate the program. Please see the "Sample Runs" section for some examples.

If the student's answer is NO, n this case, the student will be asked 3 questions consecutively, the first is what grade she received from this course in the last semester from (A, B, C, D, F, S, U), which grade she received this semester (A, B, C, D, F), and the grade she would like to choose (A, B, C, D, F, S, U). If the student gives an invalid answer other than these, the program will display the required error message and terminate the program. Please see the "Sample Runs" section.

Here, it is necessary to check the grade that the student wants to get within the framework of the conditions given above and if the grade he wants to get is valid, this grade should be printed as output and the program will be terminated. If the grade that the student wants to get is not valid within the conditions given above, the appropriate error message should be printed and the program should be closed. Below you can see which error messages are required and in which case these error messages should be printed:

If a student has received "U" the previous semester and got one of (A, B, C, D) in the current semester, students cannot choose other than S or current letter grade. In other cases, the program should output the following message:

"Invalid grade selection. If you have received U before, you may choose S" or current letter grade.

If a student has received an "S" previous semester and, got an F current semester, If a student chooses other than F, then the program should output:

"Invalid grade selection, If you have received S before and fail this semester, you get F."

If a student has received an "F" previous semester and, got an F current semester, If a student chooses other than F, the program should output :

"Invalid grade selection, If you have received F before and fail this semester, you get F."

Again, under no circumstances, the student cannot choose a higher or lower grade than the letter grade he/she has received (such as choosing B while receiving C or vice-versa). Also, students unable to choose U if he/she got a grade among (A, B, C, D) and unable to choose S if he/she got an F. If the student violates any of these situations, the program should give the following output:

"Invalid grade selection. You cannot choose a higher or lower grade than you deserve."

If the student enters a letter grade that is different than (A, B, C, D, F, S, or U), your program should give the following output:

"Invalid grade selection. Goodbye"

Finally, if the grade the student wants to get is valid within the framework of the above-mentioned rules, the program should give the following output:

"Dwight, your final grade for CS201 is C. Goodbye"

Note:Please remember that the name and course name must be taken as input from the user.

Please refer to the "Sample Runs" section for some examples and further details.

Sample Runs

Below, we provide some sample runs of the program that you will develop. The italic and bold phrases are inputs taken from the user. You have to display the required information in the same order and with the same words and characters as below.

Sample Run 1

Welcome to the Fall 2020-2021 Semester grading system. What is your name? ​John
Hello John! Please enter the name of the course to be processed: ​CS201
Hello John! If you take the CS201 for the first time, enter YES otherwise NO: ​ok
Press any key to continue . . .

Sample Run 2

Welcome to the Fall 2020-2021 Semester grading system. What is your name? ​jane
Hello jane! Please enter the name of the course to be processed: ​Cs201
Hello jane! If you take the Cs201 for the first time, enter YES otherwise NO: ​no
Press any key to continue . . .

Sample Run 3

Welcome to the Fall 2020-2021 Semester grading system. What is your name? ​jane
Hello jane! Please enter the name of the course to be processed: ​Cs204
Hello jane! If you take the Cs204 for the first time, enter YES otherwise NO: ​YES
What is your grade from (A,B,C,D,F)? ​E
Invalid grade selection. Goodbye...
Press any key to continue . . .

Sample Run 4

Welcome to the Fall 2020-2021 Semester grading system. What is your name? ​Jane
Hello Jane! Please enter the name of the course to be processed: ​Cs204
Hello Jane! If you take the Cs204 for the first time, enter YES otherwise NO: ​YES
What is your grade from (A,B,C,D,F)? ​A
Do you want to switch your grade from A to S (YES or NO)? ​no
Invalid grade selection. Goodbye...
Press any key to continue . . .

Sample Run 5

Welcome to the Fall 2020-2021 Semester grading system. What is your name? ​Dila
Hello Dila! Please enter the name of the course to be processed: ​Cs201
Hello Dila! If you take the Cs201 for the first time, enter YES otherwise NO: ​YES
What is your grade from (A,B,C,D,F)? ​B
Do you want to switch your grade from B to S (YES or NO)? ​YES
Dila, your final grade for Cs201 is S. Goodbye...
Press any key to continue . . .

Sample Run 6

Welcome to the Fall 2020-2021 Semester grading system. What is your name? ​Dila
Hello Dila! Please enter the name of the course to be processed: ​Cs201
Hello Dila! If you take the Cs201 for the first time, enter YES otherwise NO: ​YES
What is your grade from (A,B,C,D,F)? ​F
Do you want to switch your grade from F to U (YES or NO)? ​YES
Dila, your final grade for Cs201 is U. Goodbye...
Press any key to continue . . .

Sample Run 7

Welcome to the Fall 2020-2021 Semester grading system. What is your name? ​Furkan
Hello Furkan! Please enter the name of the course to be processed: ​Cs404
Hello Furkan! If you take the Cs404 for the first time, enter YES otherwise NO: ​NO
Please enter your previous grade from (A,B,C,D,F,S,U): ​C
Please enter your current grade from (A,B,C,D,F): ​G
Invalid grade selection. Goodbye...
Press any key to continue . . .

Sample Run 8

Welcome to the Fall 2020-2021 Semester grading system. What is your name? ​FURKAN
Hello FURKAN! Please enter the name of the course to be processed: ​CS201
Hello FURKAN! If you take the CS201 for the first time, enter YES otherwise NO: ​NO
Please enter your previous grade from (A,B,C,D,F,S,U): ​A
Please enter your current grade from (A,B,C,D,F): ​C
Please enter the grade you want to choose from (A,B,C,D,F,S,U): ​C
FURKAN, your final grade for CS201 is C. Goodbye...
Press any key to continue . . .

Sample Run 9

Welcome to the Fall 2020-2021 Semester grading system. What is your name? ​FURKAN
Hello FURKAN! Please enter the name of the course to be processed: ​CS201
Hello FURKAN! If you take the CS201 for the first time, enter YES otherwise NO: ​NO
Please enter your previous grade from (A,B,C,D,F,S,U): ​A
Please enter your current grade from (A,B,C,D,F): ​C
Please enter the grade you want to choose from (A,B,C,D,F,S,U): ​S
FURKAN, your final grade for CS201 is S. Goodbye...
Press any key to continue . . .

Sample Run 10

Welcome to the Fall 2020-2021 Semester grading system. What is your name? ​FURKAN
Hello FURKAN! Please enter the name of the course to be processed: CS201
Hello FURKAN! If you take the CS201 for the first time, enter YES otherwise NO: ​NO
Please enter your previous grade from (A,B,C,D,F,S,U): ​A
Please enter your current grade from (A,B,C,D,F): ​C
Please enter the grade you want to choose from (A,B,C,D,F,S,U): ​U
Invalid grade selection. You cannot choose a higher or lower grade than you deserve.
Press any key to continue . . .

Sample Run 11

Welcome to the Fall 2020-2021 Semester grading system. What is your name? ​FURKAN
Hello FURKAN! Please enter the name of the course to be processed: ​CS201
Hello FURKAN! If you take the CS201 for the first time, enter YES otherwise NO: ​NO
Please enter your previous grade from (A,B,C,D,F,S,U): ​A
Please enter your current grade from (A,B,C,D,F): ​C
Please enter the grade you want to choose from (A,B,C,D,F,S,U): ​A
Invalid grade selection. You cannot choose a higher or lower grade than you deserve.
Press any key to continue . . .

Sample Run 12

Welcome to the Fall 2020-2021 Semester grading system. What is your name? ​CREED
Hello CREED! Please enter the name of the course to be processed: ​CS201
Hello CREED! If you take the CS201 for the first time, enter YES otherwise NO: ​NO
Please enter your previous grade from (A,B,C,D,F,S,U): ​U
Please enter your current grade from (A,B,C,D,F): ​A
Please enter the grade you want to choose from (A,B,C,D,F,S,U): ​F
Invalid grade selection. If you received U before, you may choose S or current letter grade.
Press any key to continue . . .

Sample Run 13

Welcome to the Fall 2020-2021 Semester grading system. What is your name? ​CREED
Hello CREED! Please enter the name of the course to be processed: ​CS201
Hello CREED! If you take the CS201 for the first time, enter YES otherwise NO: ​NO
Please enter your previous grade from (A,B,C,D,F,S,U): ​U
Please enter your current grade from (A,B,C,D,F): ​F
Please enter the grade you want to choose from (A,B,C,D,F,S,U): ​U
CREED, your final grade for CS201 is U. Goodbye...
Press any key to continue . . .

Sample Run 14

Welcome to the Fall 2020-2021 Semester grading system. What is your name? ​CREED
Hello CREED! Please enter the name of the course to be processed: ​CS201
Hello CREED! If you take the CS201 for the first time, enter YES otherwise NO: ​NO
Please enter your previous grade from (A,B,C,D,F,S,U): ​S
Please enter your current grade from (A,B,C,D,F): ​B
Please enter the grade you want to choose from (A,B,C,D,F,S,U): ​S
CREED, your final grade for CS201 is S. Goodbye...
Press any key to continue . . .

Sample Run 15

Welcome to the Fall 2020-2021 Semester grading system. What is your name? ​BRUCE
Hello BRUCE! Please enter the name of the course to be processed: ​CS201
Hello BRUCE! If you take the CS201 for the first time, enter YES otherwise NO: ​NO
Please enter your previous grade from (A,B,C,D,F,S,U): ​S
Please enter your current grade from (A,B,C,D,F): ​C
Please enter the grade you want to choose from (A,B,C,D,F,S,U): ​C
BRUCE, your final grade for CS201 is C. Goodbye...
Press any key to continue . . .

Sample Run 16

Welcome to the Fall 2020-2021 Semester grading system. What is your name? ​BRUCE
Hello BRUCE! Please enter the name of the course to be processed: ​CS201
Hello BRUCE! If you take the CS201 for the first time, enter YES otherwise NO: ​NO
Please enter your previous grade from (A,B,C,D,F,S,U): ​S
Please enter your current grade from (A,B,C,D,F): ​F
Please enter the grade you want to choose from (A,B,C,D,F,S,U): ​C
Invalid grade selection. If you received S before and fail this semester, you get F.
Press any key to continue . . .

Sample Run 17

Welcome to the Fall 2020-2021 Semester grading system. What is your name? ​CREED
Hello CREED! Please enter the name of the course to be processed: ​CS201
Hello CREED! If you take the CS201 for the first time, enter YES otherwise NO: ​NO
Please enter your previous grade from (A,B,C,D,F,S,U): ​U
Please enter your current grade from (A,B,C,D,F): ​A
Please enter the grade you want to choose from (A,B,C,D,F,S,U): ​S
CREED, your final grade for CS201 is S. Goodbye...
Press any key to continue . . .

Sample Run 18

Welcome to the Fall 2020-2021 Semester grading system. What is your name? ​BRUCE
Hello BRUCE! Please enter the name of the course to be processed: ​CS204
Hello BRUCE! If you take the CS204 for the first time, enter YES otherwise NO: ​NO
Please enter your previous grade from (A,B,C,D,F,S,U): ​S
Please enter your current grade from (A,B,C,D,F): ​F
Please enter the grade you want to choose from (A,B,C,D,F,S,U): ​U
Invalid grade selection. If you received S before and fail this semester, you get F.
Press any key to continue . . .

Sample Run 19

Welcome to the Fall 2020-2021 Semester grading system. What is your name? ​WAYNE
Hello WAYNE! Please enter the name of the course to be processed: ​CS201
Hello WAYNE! If you take the CS201 for the first time, enter YES otherwise NO: ​NO
Please enter your previous grade from (A,B,C,D,F,S,U): ​F
Please enter your current grade from (A,B,C,D,F): ​F
Please enter the grade you want to choose from (A,B,C,D,F,S,U): ​U
Invalid grade selection. If you received F before, and fail this semester, you get F.
Press any key to continue . . .

Sample Run 20

Welcome to the Fall 2020-2021 Semester grading system. What is your name? ​BRUCE
Hello BRUCE! Please enter the name of the course to be processed: ​CS201
Hello BRUCE! If you take the CS201 for the first time, enter YES otherwise NO: ​NO
Please enter your previous grade from (A,B,C,D,F,S,U): ​F
Please enter your current grade from (A,B,C,D,F): ​F
Please enter the grade you want to choose from (A,B,C,D,F,S,U): ​F
BRUCE, your final grade for CS201 is F. Goodbye...
Press any key to continue . . .

Sample Run 21

Welcome to the Fall 2020-2021 Semester grading system. What is your name? ​BRUCE
Hello BRUCE! Please enter the name of the course to be processed: ​CS204
Hello BRUCE! If you take the CS204 for the first time, enter YES otherwise NO: ​NO
Please enter your previous grade from (A,B,C,D,F,S,U): ​A
Please enter your current grade from (A,B,C,D,F): ​B
Please enter the grade you want to choose from (A,B,C,D,F,S,U): ​U
Invalid grade selection. You cannot choose a higher or lower grade than you deserve.
Press any key to continue . . .

Sample Run 22

Welcome to the Fall 2020-2021 Semester grading system. What is your name? ​ERAY
Hello ERAY! Please enter the name of the course to be processed: ​CS201
Hello ERAY! If you take the CS201 for the first time, enter YES otherwise NO: ​NO
Please enter your previous grade from (A,B,C,D,F,S,U): ​F
Please enter your current grade from (A,B,C,D,F): ​A
Please enter the grade you want to choose from (A,B,C,D,F,S,U): ​A
ERAY, your final grade for CS201 is A. Goodbye...
Press any key to continue . . .

Sample Run 23

Welcome to the Fall 2020-2021 Semester grading system. What is your name? jane
Hello jane! Please enter the name of the course to be processed: cs201
Hello jane! If you take the cs201 for the first time, enter YES otherwise NO: YES
What is your grade from (A,B,C,D,F)? B
Do you want to switch your grade from B to S (YES or NO)? NO
jane, your final grade for cs201 is B. Goodbye...
Press any key to continue . . .
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.