Create an empty student transcript data structureprovide an


You will work with structs and linked lists to maintain a university's course catalog, as well as an individual student's transcript. This is an individual programming assignment.

Your program will:

Read the course catalog from a text file and insert into a data structure.

Create an empty student transcript data structure.

Provide an interactive menu, which allows the user to manipulate these two structures.

Relevant readings include:

Kernighan and Ritchie, Chapters 5-7

Deitel and Deitel, Chapters 7, 9, 10, 11. Section 12.4 covers linked lists.

Class notes on how to avoid memory leaks with valgrind.

Catalog

The catalog data structure is an array used to store information about all the courses offered. You will populate this data structure from a text file, the name of which will be passed in as a command line argument (i.e., you will execute the program by typing a line such as ./hw5 catalog.txt), a sample of which we will provide to you.

The number of courses in the catalog is not known ahead of time; you will need to compute it, and allocate memory for the array accordingly. The format of the input file is similar to (but not exactly the same as) that of homework 1 and 3. Each line of the file will contain a single course listing, with the following format:

xx.ddd.nnn c.f Course Title

Note the spaces between nnn, c.f, and the course title. The title may consist of multiple words. You may assume that the provided file will not contain any duplicate course identifiers. You may also assume that all file lines contain valid course listings.

You will need to define a struct to represent individual courses; the struct should contain at least the following information:

Course Division: (xx), a two character string.

Course Department: (ddd), a three-digit number.

Course Number: (nnn), a three-digit number.

Credit Assignment: (c.f), a floating point number

Course Title: a string of at most 32 characters

These limitations will also serve as your validation rules to check for invalid input for these items in the user stdin input below. We don't require you to check anything more than what is specified here, and the course division is case-insensitive.

Transcript

The transcript will represent all courses taken by a single student. These courses are entered by the user during program execution via an interactive menu. The transcript data structure is a linked-list representing the courses taken by that student, along with the semester they took the course in (fall/spring and year), and the grade they received.

Each course in the transcript should be represented by an instance of a struct that you define. This struct is different from the struct discussed above for holding catalog entries. This struct must additionally contain information about semester and grade. It must also contain any pointers required to form the linked list.

The entire transcript for a student (all semesters) must be contained in a single linked list, stored in order by semester, from the semester earliest in time to latest. For a given semester, items should be stored in the order in which they were added to the transcript, with the most recent addition first. Do not spread the transcript entries across multiple, disconnected lists. The text representation of a semester is yyyy.s where yyyy is the year and s is F for Fall or S for Spring. The text representation of a grade is Gg, where G is the letter grade and g is +, - or / (for neither + nor -), as in Homework 1.

For input validation, you should check that the criteria mentioned here are met (i.e. yyyy = 4 numbers, semester is F/S and is case insensitive, grade is a valid case-insensitive grade letter with +/- or /).

Hint: Give serious thought avoiding data duplication in your data structures, and what would happen if you were to update the details of a course after it had been added to a transcript. This line of thought should suggest to you a good implementation for the list.

Interface

Your program will interact with the user via a menu loop, as in previous homeworks. Include the prompts.c file in your code to handle all major printing to the screen. When prompting the user for the next command, your program should use the menu_prompt() function supplied to print the menu of choices, and then receive user input from stdin. Once the user command has been executed, you'll return to the main loop and use menu_prompt() again.

You should not print anything else. Remember that your output must match ours for us to test your code. Following are the commands to be supported.

q. Quit

Command format: q

No output; just exit the program. Make sure to free any memory you allocated.

1. Display the catalog:

Print complete information on all of the courses available.

Command format: 1

Output format: one course per line, each course formatted as

xx.ddd.nnn c.f Course Title\n

if the catalog is empty, print nothing.

2. Display information on a specific course in the catalog:

Selected using the input 2

Print the prompt in course_prompt().

Receive a course identifier (xx.ddd.nnn) as input. If the input is invalid, print invalid_input_msg() and return to b.

If the course does not exist in the catalog, display course_absent_msg() and go back to step b.

Print the corresponding credit assignment and course title from the catalog in the format

xx.ddd.nnn c.f Course Title\n

3. Update the title of a specific course:

Selected by the input 3

Display course_prompt()

Receive a course identifier (xx.ddd.nnn) from stdin. If the input is invalid, print invalid_input_msg() and return to b.

If the course does not exist in the catalog, display course_absent_msg() and go back to step b.

Display new_title_prompt()

Receive the new course title from the user. If the title is invalid, print invalid_input_msg() and return to step e.

Update the corresponding course's entry in the catalog with the new title and print course_updated_msg(). All transcript-added instances of this course must have the same new title.

4. Update the credit assignment of a specific course:

Selected using the input 4

Display course_prompt()

Receive a course identifier (xx.ddd.nnn) from stdin. If the input is invalid, print invalid_input_msg() and return to b.

If the course does not exist in the catalog, display course_absent_msg() and go back to step b.

Display new_credit_prompt().

Receive the new credit assignment as input in c.f format. If the credit input is invalid, display invalid_input_msg() and return to step e.

Update the corresponding course's entry in the catalog with the new credit assignment and print course_updated_msg(). All transcript-added instances of this course must have the same new credit assignment.

5. Add a course to the student transcript:

Selected using the input 5

Display course_prompt()

Receive a course identifier (xx.ddd.nnn) from stdin. If the input is invalid, print invalid_input_msg() and return to step b.

If the course does not exist in the catalog, display course_absent_msg() and go back to step b.

Display semester_prompt()

Receive the semester in yyyy.s format. If the format isn't valid, display invalid_input_msg() and go back to e.

Display grade_prompt()

Receive the grade in Gg format. If the input is invalid, display invalid_input_msg() and go back to g.

If the same course with the same semester already exists in the list, display duplicate_course_msg() and return to step b.

Add the corresponding entry to the transcript list. Print transcript_updated_msg().

6. Remove a course from the student transcript: (if the transcript is empty, loop back to the main menu)

Selected using the input 6

Display course_prompt()

Receive a course identifier (xx.ddd.nnn) from stdin. If the identifier is invalid, display invalid_input_msg() and return to b.

If the course does not exist in the catalog, display course_absent_msg() and go back to step b.

If the course does not exist in the transcript, display course_not_taken_msg() and go back to step b.

If the course exists only once in the transcript, delete it from the transcript list and display transcript_updated_msg(). Skip the rest of the steps and return to the menu.

If the course exists more than once in the transcript, display semester_prompt().

Receive the semester in yyyy.s format. If the semester is invalid or the course wasn't take in that semester, return to g (notice no message).

Delete the specific course from the transcript list and display transcript_updated_msg()

7. Display the current transcript:

Select using the input 7

Print all the courses in the transcript in the format

yyyy.s Gg xx.ddd.nnn c.f Course Title\n

The courses must appear in order by semester, from the semester earliest in time to latest. For a given semester, items should appear in the order in which they were added to the transcript, with the most recent addition first. If no courses appear in the transcript, output empty_transcript_msg().

8. Display information about a specific course in the transcript: (if the transcript is empty, loop back to the main menu)

Select using the input 8

Display course_prompt()

Receive a course identifier (xx.ddd.nnn) from stdin. If the identifier is invalid, display invalid_input_msg() and return to b.

If the course does not exist in the catalog, display course_absent_msg() and go back to step b.

If the course does not exist in the transcript, display course_not_taken_msg() and go back to step b.

For all semesters in which the course was taken, display the semester and grade in the format

yyyy.s Gg\n

one semester entry per line.

9. Compute the cumulative GPA for the student:

Select using the input 9

Calculate the GPA based on the courses currently in the transcript. Don't forget to weight each class according to the credit assignment, as you did in Homework 1.

Output the GPA using the gpa_msg() function, passing in the gpa argument. If there are no courses currently in the transcript, pass in a 0.

All output should be written to the standard output stream.

We are providing a sample input file catalog1.txt from which you can populate your catalog.

Testing

When we test your submission, we will test whether it adheres to the descriptions above. The best way to accumulate points on the assignment is to outsmart us by writing your own tests first, and making sure your submission passes those tests. As stated above, you must submit a Makefile containing a target called unittest that compiles unit tests. Additionally, you should have a shell script similar to the one from the last homework that runs end-to-end tests, comparing output to expected output. You should add new tests as soon as you think of them. You can't know exactly which tests we're going to run when grading, but you can probably make some good guesses.

Testing shell script

Once again, you'll want to use a shell script for your end-to-end tests. One is provided here.

General Requirements

Your program should accept a single command line argument, the name of the file which you will use to populate the catalog structure.

Your program should not have any memory leaks. That is, for any chunk of memory that you allocate using malloc or a similar function, you must be sure to deallocate it using free as soon as you don't need it anymore. Use valgrind to make sure your program has no memory leaks, and also to make sure you don't have any invalid memory accesses.

For efficiency, your program should use sharing via pointers of large data structures, to avoid passing large structures by value where possible.

For scalability, your program should avoid code duplication as much as possible using variables, common function calls, and/or pointers.

Submission

Optional README, containing a brief note about your code and any issues you want to convey to the graders.

Makefile with at least targets called hw5 for building your solution executable, and unittest for building your unit tests.

The provided, unchanged prompts.c.

All source and header files needed to build hw5 and unittest. We are not mandating particular file names or ways of splitting functions across files. That's up to you.

test.sh: the testing script

Test files: catalog#.txt, in#.txt, out#.txt to run the input commands on the specific catalog and compare to the out file. Substitute for # from 1 to the highest test number used.

Request for Solution File

Ask an Expert for Answer!!
Data Structure & Algorithms: Create an empty student transcript data structureprovide an
Reference No:- TGS02880806

Expected delivery within 24 Hours