Question: Write a small C++ program. Your program should compile correctly and produce the specified output. Please note that the computer program should comply with the

Write a small C++ program. Your program should compile correctly and produce the specified output. Please note that the computer program should comply with the commenting and formatting rules as has been done in class. For example, there should be a header for the whole program that gives the author’s name, class name, date, and description. End braces should be commented, and there are alignment and indenting requirements as discussed. Please ask if you have any questions.

Description

This program covers: flow control (branch and loops); input and output (formatting); arrays, dynamic array and C-strings; classes and inheritance and linked lists. Refer to the respective chapter for details.

A student is enrolled in two or more courses during a typical semester. Each course’ final grade is computed based on different number of tasks like assignments, quizzes and exams. Assume that all exams represent 60% of the final grade, home works 30% and all quizzes 10%.

All the grades are stored in a text file named grades.txt. The format is:

Where:

  • TYPE: is an integer representing an enum with values EXAM=0, HOMEWORK=1, QUIZ = 2, FINAL_GRADE=3;
  • COURSE PREFIX AND NUMBER: is a string, representing the class id for each course. i.e. CS1337 where CS is the prefix and 1337 is the class number
  • GRADE: a double value [0 to 100], representing the grade for the task
  • DATE: represents the date the grade was given. Use the format YYYYMMDD. i.e. February 28th, 2020 is represented as 20200228.

For example:

            0          CS1337           89        20200228       

            1          CS2305           95        2010125

            1          CS1337           100      20200203

            2          PHY1305        67        20200128

The above represents the grades of one exam and one homework for CS1337; one homework for CS2305 and one quiz for PHY1305.

Based on the information collected for each course, the averages (exams, home works and quizzes) will be used to compute the final grade (60% exams, 30% home works and 10% quizzes)

The program

You will write a program to read the input file, store the information in the proper data structure(class/linked list), display a menu and perform the corresponding action.

i)          Define a base class with the following data members, including constructor, destructor (to release dynamically allocated memory) and assessors and mutators:

  • char * courseName;   // To store class prefix and number
  • TYPE task: // Enum type to represent EXAM, HW, QUIZ or FINAL
  • double grade;    // A double value from 0 to 100
  • double date;   // A double value representing the date

ii)         Derive a class from i) and call it “node”, adding the data members, assessors and mutators needed to be used as a node in a doubly linked list.

iii)         Implement a doubly linked list, and name it “grades”, using the class in ii). Include (at least) the following operation:

  • Insert, remove and find node.
  • Any other method needed

iv)        Read the input file “grades.txt” and store this information in the linked list grades.

v)         Define another doubly linked list, and name it “courses”. Each node in this linked list represent one course(identified by prefix and number) and the final grade.

vi)        Display a menu

                        a) Display all final grades

                        b) Display course grades

                        c) Semester Average

                        d) Exit

When option a is selected, for each different course, compute the averages (exams, homeworks and quizzes); using the percentages given before (60%, 30% and 10%), compute the final grade, and use a table format to display final grades, indicating with – (minus) the smallest grade and +(plus) the highest grade. For example

                        COURSE No.                         FINAL GRADE           NOTE

                        CS1337                                       99.0                             -

                        CS2305                                      100.0                            +

                        PHY1305                                    89.0                           

When option b is selected, you first ask for the course prefix and number (i.e. CS1337), if the course prefix or number is not found, your program should display a message indicating it. Otherwise, using the table format below, display all the information about the course. For example, say that class prefix and number CS1337 was entered:

            COURSE                    GRADE          TYPE             DATE

            CS1337                       98.5                EXAM            20200228

            CS1337                       100.0              HW                 20200203

            CS1337                       99.0                QUIZ              20200214

When option c is selected, the program will compute the semester average as the sum of the final grades, divided by the number of courses taken, and display a message like:

            THIS SEMESTER YOUR AVERAGE WAS 97.9/100!

When option d is selected, the program will terminate.

When any other option is selected, the program should display a message, indicating that the entered option was invalid.

Continue displaying the menu, until option d is chosen.

Note: you can create your own input file for testing purposes.

Deliverables

You will turn in a Text (grades.txt) file and the C++ source code files(.h and .cpp).

The C source code file should:

            1) Comply with all of the formatting requirements already discussed.

            2) Display the output

Step by Step Solution

3.45 Rating (161 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

include in... View full answer

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 Mathematics Questions!