Create an empty student transcript data structure

Assignment Help Data Structure & Algorithms
Reference no: EM132087347

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<newline>

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<newline>

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<newline>

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<newline>

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<newline>

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<newline>

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<newline>

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<newline>

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<newline>

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<newline>

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.

Reference no: EM132087347

Questions Cloud

Explain how the equation e : Explain how the equation E = hf could mean that light is a particle and a wave at the same time.
How many photons are arriving at the collector each second : If the peak intensity of this sunlight has a wavelength of 5.60 x 10-7 m, how many photons are arriving at the collector each second?
Calculate the answer in ev and in joules : How much energy is needed to move an electron in a hydrogen atom from the ground state (n=1) to n=3? Calculate the answer in eV and in joules.
Investigation of passive radiative cooling on a building : ENRP20001 - Engineering Research Project Planning - Topic for the literature review is Investigation of passive radiative cooling on a residential building
Create an empty student transcript data structure : Create an empty student transcript data structure.Provide an interactive menu, which allows the user to manipulate these two structures.
Find the number of addresses in each subnet : An organization is granted the IPv4 address blockm130.56.0.0/16. The network administrator wants to create 1024 subnets .
Analyzing the Marketing Environment : What do you think are the three major trends in your selected macro-environment that have the potential to impact the marketing of the selected product category
Acceleration of a car traveling with a constant velocity : What is the acceleration of a car traveling with a constant velocity when its engine produces a constant force of 20,000 N?
How are organizations strengthening defense : How can the administrator ensure that no important task in the ongoing management of security in networks is neglected?

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Implement an open hash table

In this programming assignment you will implement an open hash table and compare the performance of four hash functions using various prime table sizes.

  Use a search tree to find the solution

Explain how will use a search tree to find the solution.

  How to access virtualised applications through unicore

How to access virtualised applications through UNICORE

  Recursive tree algorithms

Write a recursive function to determine if a binary tree is a binary search tree.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Currency conversion development

Currency Conversion Development

  Cloud computing assignment

WSDL service that receives a request for a stock market quote and returns the quote

  Design a gui and implement tic tac toe game in java

Design a GUI and implement Tic Tac Toe game in java

  Recursive implementation of euclids algorithm

Write a recursive implementation of Euclid's algorithm for finding the greatest common divisor (GCD) of two integers

  Data structures for a single algorithm

Data structures for a single algorithm

  Write the selection sort algorithm

Write the selection sort algorithm

  Design of sample and hold amplifiers for 100 msps by using n

The report is divided into four main parts. The introduction about sample, hold amplifier and design, bootstrap switch design followed by simulation results.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd