Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M93074820

Have any Question?


Related Questions in Computer Engineering

Compare remote authentication dial-in user service radius

Compare Remote Authentication Dial-In User Service (RADIUS) and Terminal Access Controller Access-Control System Plus (TACACS+).

In linux what synchronization methods they use within the

In Linux what synchronization methods they use within the kernel, please dig into your findings for Linux.

Assignment 1 multi-touch screens vs mouse-driven screensthe

Assignment 1: Multi-Touch Screens vs. Mouse-Driven Screens The following resources may be helpful when completing this assignment. • Dearden, A. (2008). User-Centered Design Considered Harmful • Norman, D. (2007-2010). A ...

Technology certainly does play a large role in our lives

Technology certainly does play a large role in our lives and this has happened in a very short period of time. It has impacted the way we activities professionally, personally, and academically. For example, online educa ...

Recursive algorithms help c programmingquestion create an

Recursive algorithms help C++ programming: question: Create an ADT that contains a fixed-size array that holds 20 integers (i.e., int array[20]; ) and the following member functions: A default constructor that initialize ...

Suppose that you are given a sorted list of n elements

Suppose that you are given a sorted list of n elements followed by f(n) randomly ordered elements. How would you sort the entire list if a. f(n) = 2? b. f(n) = vn? c. How large can f(n) be for the entire list to be sorte ...

How is the study of how firms decisions about prices and

How is the study of how firms' decisions about prices and quantities depend on the market conditions they face, the field of industrial organization, and the cost of production.

What is the purpose of load balancing i need full

What is the purpose of load balancing? (I need full explanation) I already know what load balancing is, I just need to know why we use it

Wat are three 3 major categories of cyber terrorism and

What are three (3) major categories of cyber terrorism and / or information warfare. Among the chosen categories, determine the one (1) that should be the top priority for the federal government to address.

Answer the question given belowwhat is the relationship

Answer the question given below What is the relationship between a context diagram and diagram 0, and which symbol is not used in a context diagram? The response must be typed, single spaced, must be in times new roman f ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As