1 Background

In this assignment you will write a simple program that manages a set of courses a student is taking. This program will introduce new keywords (struct, enum), and the handling of heap memory allocations. Similar to the last assignment, we ask that you do your program development on Linux.

The program will store a collection of courses, giving the user options to add to the collection, or remove from that collection. The collection of courses will be stored as a linked list (using structs as nodes). The problem must support any number of courses in the collection. Courses will be composed of a subject (enum), number, teacher, and number of credits. When a user adds a course, a new node must be created, and when a course is removed, its corresponding node is removed.

2 Requirements

For this assignment you will write a course scheduler program in C. Your program must:

  • Compile on GCC 5.3 or greater under an Ubuntu based Linux distribution (e.g., Xu- buntu).
  • Have an enumeration type (called Subject) to represent subjects ("SER=0, EGR=1, CSE=2, EEE=3").
  • Have a struct type (called CourseNode) to hold information about a course. Include a subject (see enum type above), a number (int), a teacher (a string of length 1024), and credit hours (int). It should also include the variables necessary to represent a linked list.
  • Use a linked list of structs (called course_collection) to store course information. Your program will allow the user to enter any number of courses - this means you must use dynamic memory allocation to store the courses. When a user adds a course, a new node must be created, and when a course is removed, its corresponding node is removed.

Note: your program may not exactly match the outputs below - screen shots are only provided as samples. Points allocation is:

  • Update the main menu to display the total number of credits each time it is shown. see image.
  • The program must not leak memory on exit.
  • Create a void course_insert() function that adds courses to the collection and keeps it sorted by the course number (e.g. 240). Sorting by subject is not required. Populate the elements of the CourseNode as shown below. Two example inserts are shown. see image.
  • Properly allocate memory when removing nodes. No memory leaks.
  • Create a void schedule_print() function. This function will display the contents of the course_collection list with format Subject Number Credits Teacher as shown. (Hint: Use a switch statement to map from a enumeration to a printf.) see image.
  • Create a void course_drop() function. This function will prompt the user for a course by its number. It then searches for the course in course_collection and removes it. If more than one course matches, then drop only the first occurrence. Dropping a course is only allowed if the course exists in the collection, otherwise an error message will be displayed see image.
  • Properly deallocate memory when removing nodes. No memory leaks.
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.