Question

In: Computer Science

After the Coronavirus affected the whole world, the grading system of Schrute University, like many universities,...

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 student’s 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).

, you will implement a C++ program that calculates the course grade of a Schrute University

  • Name of the student,
  • Name of the course,
  • Whether she/he took the lesson for the first time, and
  • Current or previous term grade if available (if (3) is valid).
  • 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.

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 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…”

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 . . .

Solutions

Expert Solution

#include <iostream>
using namespace std;

string name, course, _previous,_current, _final;

void printInvalid()
{
    cout<<"Invalid grade selection. Goodbye...";
}
void printFinal()
{
    cout<<name<<", your final grade for "<<course<<" is "<<_final<<". Goodbye...";
}
void gradeMismatch1()
{
    cout<<"Invalid grade selection. If you have received "<<_previous<<" before, you may choose “S” or current letter grade.";
}
void gradeMismatch2()
{
    cout<<"Invalid grade selection. You cannot choose a higher or lower grade than you deserve.";
}
void gradeMismatchFail()
{
    cout<<"Invalid grade selection, If you have received "<<_previous<<" before and fail this semester, you get F.";
    _final="F";
}
void unrepeatedCourse()
{
    string choice;
    cout<<"What is your grade from (A,B,C,D,F)? ";
    cin >> _previous;
    if(_previous == "A" or _previous =="B" or _previous =="C" or _previous =="D" or _previous =="F")
    {
        if(_previous == "F")
        {
            cout << "Do you want to switch your grade from " << _previous << " to U (YES or NO)? ";
            cin>>choice;
            if(choice=="YES" or choice=="yes")
            {
                _final = "U";
                printFinal();
            }
            else if(choice=="NO" or choice=="no")
            {
                printInvalid();
            }
        }
        //prev is A/B/C/D
        else
        {
            cout << "Do you want to switch your grade from " << _previous << " to S (YES or NO)? ";
            cin>>choice;
            if(choice=="YES" or choice=="yes")
            {
                _final = "S";
                printFinal();
            }
            else if(choice=="NO" or choice=="no")
            {
                printInvalid();
            }
        }
    }
    //invalid grade selection i,e other than available
    else
    {
        printInvalid();
    }
}

void repeatedCourse()
{
    cout<<"Please enter your previous grade from (A,B,C,D,F,S,U): ";
    cin >> _previous;
    if(_previous == "A" or _previous == "B" or _previous == "C" or _previous == "D" or _previous == "F" or _previous == "S" or _previous == "U")
    {
        if(_previous == "U")
        {
            cout<<"Please enter your current grade from (A,B,C,D,F): ";
            cin >> _current;
            if(_current == "A" or _current == "B" or _current ==  "C" or _current ==  "D" or _current ==  "F")
            {
                if(_current == "A" or _current == "B" or _current ==  "C" or _current ==  "D")
                {
                    //final s
                    cout<<"Please enter the grade you want to choose from (A,B,C,D,F,S,U): ";
                    cin>>_final;
                    if(_final == "A" or _final =="B" or _final =="C" or _final =="D" or _final =="F" or _final =="S" or _final =="U")
                    {
                        if(_final=="S" || _final==_current)
                            printFinal();
                        else
                            gradeMismatch1();
                    }
                    else
                    {
                        //invalid final
                        printInvalid();
                    }
                }
                //_current F
                else
                {
                    //final u or f
                    cout<<"Please enter the grade you want to choose from (A,B,C,D,F,S,U): ";
                    cin>>_final;
                    if(_final == "A" or _final =="B" or _final =="C" or _final =="D" or _final =="F" or _final =="S" or _final =="U")
                    {
                        if(_final=="U" || _final=="F")
                            printFinal();

                        else
                            gradeMismatchFail();
                    }
                    else
                    {
                        //invalid final
                        printInvalid();
                    }
                }
            }
            else
            {
                printInvalid();
            }
        }
        else if(_previous == "S")
        {
            cout<<"Please enter your _current grade from (A,B,C,D,F): ";
            cin >> _current;
            if(_current == "A" or _current == "B" or _current ==  "C" or _current ==  "D" or _current ==  "F")
            {
                if(_current == "A" or _current == "B" or _current ==  "C" or _current ==  "D")
                {
                    //final s
                    cout<<"Please enter the grade you want to choose from (A,B,C,D,F,S,U): ";
                    cin>>_final;
                    if(_final == "A" or _final =="B" or _final =="C" or _final =="D" or _final =="F" or _final =="S" or _final =="U")
                    {
                        if(_final=="S" or _final==_current)
                            printFinal();
                        else
                            gradeMismatch1();
                    }
                    else
                    {
                        //invalid Final
                        printInvalid();
                    }
                }
                //_current f
                else
                {
                    //final f
                    cout<<"Please enter the grade you want to choose from (A,B,C,D,F,S,U): ";
                    cin>>_final;
                    if(_final == "A" or _final =="B" or _final =="C" or _final =="D" or _final =="F" or _final =="S" or _final =="U")
                    {
                        if(_final=="F")
                            printFinal();
                        else
                            gradeMismatchFail();
                    }
                    else
                    {
                        //invalid final
                        printInvalid();
                    }
                }
            }
            else
            {
                //invalid current
                printInvalid();
            }
        }
        //prev=a/b/c/d/f?
        else {
            //prev f
            if (_previous == "F")
            {
                cout << "Please enter your _current grade from (A,B,C,D,F): ";
                cin >> _current;
                if (_current == "A" or _current =="B" or _current =="C" or _current =="D" or _current =="F") {
                    cout << "Please enter the grade you want to choose from (A,B,C,D,F,S,U): ";
                    cin >> _final;
                    if (_final == "A" or _final =="B" or _final =="C" or _final =="D" or _final =="F" or _final =="S" or _final =="U") {
                        if (_final == "F") {
                            printFinal();
                        } else {
                            gradeMismatchFail();
                        }
                    } else {
                        //invalid final
                        printInvalid();
                    }
                }
                else
                {
                    //invalid current
                    printInvalid();
                }

            }
            //prev a,b,c,d
            else
            {
                cout << "Please enter your _current grade from (A,B,C,D,F): ";
                cin >> _current;
                if (_current == "A" or _current =="B" or _current =="C" or _current =="D" or _current =="F")
                {
                    if (_current == "F")
                    {
                        cout << "Please enter the grade you want to choose from (A,B,C,D,F,S,U): ";
                        cin >> _final;
                        if (_final == "A" or _final =="B" or _final =="C" or _final =="D" or _final =="F" or _final =="S" or _final =="U")
                        {
                            if (_final == "F")
                            {
                                printFinal();
                            }
                            else
                            {
                                gradeMismatchFail();
                            }
                        }
                        else{
                            //invalid final
                            printInvalid();
                        }
                    }
                    //current a/b/c/d
                    else
                    {
                        cout << "Please enter the grade you want to choose from (A,B,C,D,F,S,U): ";
                        cin >> _final;
                        if (_final == "A" or _final =="B" or _final =="C" or _final =="D" or _final =="F" or _final =="S" or _final =="U")
                        {
                            if (_final == "S" or _final == _current)
                            {
                                printFinal();
                            }
                            else
                            {
                                gradeMismatch2();
                            }
                        }
                        else{
                            //invalid final
                            printInvalid();
                        }
                    }
                }
                else
                {
                    //invalid current
                    printInvalid();
                }
            }
        }
    }
    else
    {
        //prev invalid
        printInvalid();
    }
}

int main()
{

        string isFirstTime;
        cout<<"Welcome to the Fall 2020-2021 Semester grading system. What is your name?";
        getline(cin, name);
        cout<<"Hello "<<name<<"! Please enter the name of the course to be processed:";
        cin>>course;
        cout<<"Hello "<<name<<"! If you take the "<<course<<" for the first time, enter YES otherwise NO:";
        cin >> isFirstTime;
        if(isFirstTime == "YES" or isFirstTime =="yes"){
            unrepeatedCourse();
        }
        else if (isFirstTime == "NO" or isFirstTime =="no"){
            repeatedCourse();
        }
        cout<<"\nPress any key to continue . . .\n\n";
}

Related Solutions

A large University system, which currently uses a standard grading system of A, B, C, D...
A large University system, which currently uses a standard grading system of A, B, C, D or F for their students, is analyzing the possibility of changing to a plus-minus grading policy. In addition to the computer system, which stores and manages all the student records, the faculty and the students would also be affected by this possible change. One of the concerns that students have, is that changing this policy might lower the overall GPA (grade point average) of...
Do larger universities tend to have more property crime? University crime statistics are affected by a...
Do larger universities tend to have more property crime? University crime statistics are affected by a variety of factors. The surrounding community, accessibility given to outside visitors, and many other factors influence crime rate. Let x be a variable that represents student enrollment (in thousands) on a university campus, and let y be a variable that represents the number of burglaries in a year on the university campus. A random sample of n = 8 universities in California gave the...
Do larger universities tend to have more property crime? University crime statistics are affected by a...
Do larger universities tend to have more property crime? University crime statistics are affected by a variety of factors. The surrounding community, accessibility given to outside visitors, and many other factors influence crime rate. Let x be a variable that represents student enrollment (in thousands) on a university campus, and let y be a variable that represents the number of burglaries in a year on the university campus. A random sample of n = 8 universities in California gave the...
Do larger universities tend to have more property crime? University crime statistics are affected by a...
Do larger universities tend to have more property crime? University crime statistics are affected by a variety of factors. The surrounding community, accessibility given to outside visitors, and many other factors influence crime rate. Let x be a variable that represents student enrollment (in thousands) on a university campus, and let y be a variable that represents the number of burglaries in a year on the university campus. A random sample of n = 8 universities in California gave the...
Do larger universities tend to have more property crime? University crime statistics are affected by a...
Do larger universities tend to have more property crime? University crime statistics are affected by a variety of factors. The surrounding community, accessibility given to outside visitors, and many other factors influence crime rate. Let x be a variable that represents student enrollment (in thousands) on a university campus, and let y be a variable that represents the number of burglaries in a year on the university campus. A random sample of n = 8 universities in California gave the...
Do larger universities tend to have more property crime? University crime statistics are affected by a...
Do larger universities tend to have more property crime? University crime statistics are affected by a variety of factors. The surrounding community, accessibility given to outside visitors, and many other factors influence crime rate. Let x be a variable that represents student enrollment (in thousands) on a university campus, and let y be a variable that represents the number of burglaries in a year on the university campus. A random sample of n = 8 universities in California gave the...
Do larger universities tend to have more property crime? University crime statistics are affected by a...
Do larger universities tend to have more property crime? University crime statistics are affected by a variety of factors. The surrounding community, accessibility given to outside visitors, and many other factors influence crime rate. Let x be a variable that represents student enrollment (in thousands) on a university campus, and let y be a variable that represents the number of burglaries in a year on the university campus. A random sample of n = 8 universities in California gave the...
Do larger universities tend to have more property crime? University crime statistics are affected by a...
Do larger universities tend to have more property crime? University crime statistics are affected by a variety of factors. The surrounding community, accessibility given to outside visitors, and many other factors influence crime rate. Let x be a variable that represents student enrollment (in thousands) on a university campus, and let y be a variable that represents the number of burglaries in a year on the university campus. A random sample of n = 8 universities in California gave the...
Do larger universities tend to have more property crime? University crime statistics are affected by a...
Do larger universities tend to have more property crime? University crime statistics are affected by a variety of factors. The surrounding community, accessibility given to outside visitors, and many other factors influence crime rate. Let x be a variable that represents student enrollment (in thousands) on a university campus, and let y be a variable that represents the number of burglaries in a year on the university campus. A random sample of n = 8 universities in California gave the...
The coronavirus is currently wreaking havoc on the world economy. There are many reasons for this,...
The coronavirus is currently wreaking havoc on the world economy. There are many reasons for this, so let’s simplify by focusing on just one. Suppose the primary effect of the coronavirus is to create “uncertainty”, which leads investors to increase their demand for “liquidity” (i.e., it increases the demand for money relative to other assets). Use the DD-AA model to show how this would affect the US economy. What happens to US output and the value of the dollar? US...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT