Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a menu-driven C++ program to manage your college course history and plans, named as you wish. Go back to the module on C/C++ strings,

Write a menu-driven C++ program to manage your college course history and plans, named as you wish. Go back to the module on C/C++ strings, because you're going to need C strings in this one.

It should work something like this:

Array size: 0, capacity: 2 MENU A Add a course L List all courses C Arrange by course Y arrange by Year U arrange by Units G arrange by Grade Q Quit ...your choice: a[ENTER] Enter a courses' name: Comsc-165[ENTER] Enter the year for Comsc-165 [like 2016]: 2016[ENTER] Enter the units for Comsc-165 [0, 1, 2,...]: 4[ENTER] Enter the grade for Comsc-165 [A, B,..., X if still in progress or planned]: x[ENTER] Array size: 1, capacity: 2 MENU A Add a course L List all courses C Arrange by course Y arrange by Year U arrange by Units G arrange by Grade Q Quit ...your choice: a[ENTER] Enter a courses' name: Comsc-110[ENTER] Enter the year for Comsc-110 [like 2016]: 2015[ENTER] Enter the units for Comsc-110 [0, 1, 2,...]: 4[ENTER] Enter the grade for Comsc-110 [A, B,..., X if still in progress or planned]: A[ENTER] Array size: 2, capacity: 2 MENU A Add a course L List all courses C Arrange by course Y arrange by Year U arrange by Units G arrange by Grade Q Quit ...your choice: l[ENTER] Course Year Units Grade ---------- ---- ----- ----- COMSC-165 2016 4 X COMSC-110 2015 4 A Array size: 2, capacity: 2 MENU A Add a course L List all courses C Arrange by course Y arrange by Year U arrange by Units G arrange by Grade Q Quit ...your choice: q[ENTER] 

Requirements

Use a dynamic array of struct-based objects.

Allow for course names up to 12 characters in length, like Comsc-150sql. Do not use C++ strings -- they will not serialize to a binary file. Use only C strings in the struct.

Convert course names and grades entries to uppercase as they are inputted.

Allow units to be whole numbers or floating point, per your choice.

Allow grade to be a single char (like A, B, etc) or a C string (like A+, B-, etc), per your choice.

Use a dynamic array of objects to store the course information, with an initial capacity of 2.

Double the array capacity when (a) you have a new object to add and (b) size equals capacity.

The output table should have nicely-spaced column headings -- refer to what you learned about cout.width.

Output the array size and capacity along with the output table.

Output blank lines to separate blocks of text as modeled in the sample output above.

Serialize using a binary file named courses.dat.

How To Arrange An Array Of Objects

Remember how to sort the integer arrays in previous lectures:

// sort the values lo-to-hi for (int i = 0; i < CAPACITY; i++) for (int j = i + 1; j < CAPACITY; j++) if (scores[j] < scores[i]) swap(scores[i], scores[j]); 

For high-to-low, simply exchange the i and j in the if-statement. swap is in the C++ algorithm library.

Functions

You don't have to write functions for everything. You may just write code blocks in main, and if it makes sense for you to move any of them out of main and into functions (like a void function to cout a table of courses), do so. Make use of the functions provided for you to copy, paste, and adapt, found in this module and the module on strings.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started