Question: Write a C++ console program that prompts a user to enter information for the college courses you have completed, planned, or are in progress, and
Write a C++ console program that prompts a user to enter information for the college courses you have completed, planned, or are in progress, and outputs it to a nicely-formatted table. Name the CPP as you wish.
Its output should look something like this:
Course Year Units Grade ---------- ---- ----- ----- comsc-110 2015 4 A comsc-165 2016 4 ? comsc-200 2016 4 ? comsc-155h 2014 4 A comsc-260 2017 4 ? bus-90 2015 4 A
Here are the requirements:
Use a struct named Course with the 4 attributes needed for the table, named as you wish.
Use int or double for Units (your choice) and char or string for Grade (your choice).
Use ? or X or some other designation for Grades for courses in progress or planned (your choice).
Track the number of objects in use in the partially filled array -- that is, the size.
Use an object array of capacity 100 in the main program to track up to 100 course objects.
Include table column headings, correctly-spaced.
The total of all column widths should not exceed 80 spaces.
You choose which attributes to left-justify, right-justify, or center.
Use the string buffer method to cin numbers.
Serialize using a text file named courses.txt.
And for structural requirements:
Never use global variables. Do not use global constants in this one, because they are not needed.
At your option, write a value-returning function of the prototype: Course cinOneCourse(int); to prompt the user for a single course, and return a filled-in Course object. The parameter's value is a sequence number: 0 or 1 for the first student, 1 or 2 for the next -- you decide whether to start at 0 or 1 in the input prompts. In main, copy the returned object to the next unused element of the array. You may use a for-loop in main to manage this.
At your option, write a void function with this prototype: void coutAllCourses(Course[ ], int); to cout the table header and all the in-use elements of the Course object array. Call the function from main, after each time a new course is added to the array. Or write it all in code blocks in main.
To end the for-loop before 100 courses get entered, allow the user to q or Q for the course. In the cinOneCourse function (or code block), skip input of the remaining attributes if the course is lowercase q or uppercase Q. In the for-loop in main that controls all this, break from the loop before calling the coutAllCourses (or code block) again if a q or Q course name is detected, and that ends the program.
Input/Output Sample:
A session might look like this, with user input in bold blue with [ENTER] to signify the Enter or Return key pressed, so that it's easier to see in the sample below. Note that it starts by outputting an empty table:
Course Year Units Grade ----------- ---- ------ ----- Enter course #1 [Q to exit]: Comsc-165[ENTER] What year for Comsc-165? [e.g., 2016]: 2016[ENTER] How many units is Comsc-165? 4[ENTER] And what was your grade [? for in-progress or planned]: ?[ENTER] Course Year Units Grade ----------- ---- ------ ----- comsc-165 2016 4 ? Enter course #2 [Q to exit]: Comsc-110[ENTER] What year for Comsc-110? [e.g., 2016]: 2015[ENTER] How many units is Comsc-110? 4[ENTER] And what was your grade [? for in-progress or planned]: A[ENTER] Course Year Units Grade ----------- ---- ------ ----- comsc-165 2016 4 ? comsc-110 2015 4 A Enter course #3 [Q to exit]: q[ENTER]
Because this uses serialization, the above 2 courses should be serialized down (that is, saved) to a TXT file, and serialized up (that is, restored) the next time the program is executed. In that case, the program would start like this:
Course Year Units Grade ----------- ---- ------ ----- comsc-165 2016 4 ? comsc-110 2015 4 A Enter course #3 [Q to exit]:
The user could then quit right away, using the program only to view the already-entered courses, or add to them.
(please use the serialization)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
