Assignment 5: File I/O course catalog database

For this assignment, you will use C’s I/O functions to create a simple course catalog database for administrators to update the details of each course offered by the CS department. The system will store basic information about each course, allowing the user to create, read, update, and delete them. All information for all courses will be stored as binary records in a single file.

Get Help With a similar task to - Assignment 5: File I/O course catalog database

Login to view and/or buy answers.. or post an answer
Additional Instructions:

Assignment 5: File I/O CS 3424 - Systems Programming Sam Silvestro - UTSA For this assignment, you will use C’s I/O functions to create a simple course catalog database for administrators to update the details of each course offered by the CS department. The system will store basic information about each course, allowing the user to create, read, update, and delete them. All information for all courses will be stored as binary records in a single file. This assignment requires only the utilities used so far in the I/O lecture notes. Do not use bash, sed, awk, find, grep, Python, or any programming languages or utilities besides the C binary functions used and discussed in class. Only binary I/O functions should be used to store data to the file system (it is acceptable to use other functions when prompting the user for command input sequences). Storing Course Information All course information will be stored in a single binary structure as records of the following structure, where name is the name of the course (which may contain spaces), schedule represents the course schedule (either strings MWF or TR), hours is the number of credit hours for the course, and size is the number of students currently enrolled in the course. You will use a zero-valued hours member value to determine and control a course’s existence/validity within the file. 1 typedef struct { 2 char name [80]; 3 char schedule [4]; 4 unsigned hours; 5 unsigned size; 6 unsigned padding ; // unused but required 7 } COURSE ; The program will store all courses using the above struct in a single file called courses.dat, located within the same directory as the program (this file is provided to you). All courses will be referenced using their course number as their index (e.g., course i will be located in the data file at relative byte off- set i * sizeof(COURSE). Course records will be stored in courses.dat in course-number order. Note that the course numbers will be specified by the user when a course is entered, and will not necessarily be sequential. If courses.dat does not exist, it should be created by the program in the current directory . You must use the files located at: /usr/local/courses/ssilvestro/cs3424/Spring21/assign5; specifically, courses.dat shall be used as the starting point for your database (i.e., you must use this file for all operations, not a blank/empty/zero-byte data file, nor any other file). Assignment 5: File I/O Page 1 of 6 Program Execution When the program is executed, the following actions should occur. All program output should appear exactly as it appears below. 1. Prior to printing the main menu your program should output a “byline,” as indicated below, only one time per execution. Substitute your particular identifying details where indicated. That is to say this message is not tied to the main menu in any way. Assignment 5 created by Sam Silvestro (bkl740) 2. Upon running your program, the user should be presented with the following menu: Enter one of the following actions or type CTRL-D to exit. C - create a new course record R - read an existing course record U - update an existing course record D - delete an existing course record 3. The user then enters a one-character action (either upper or lowercase), leading to one of the following. • C: a course is created (a) The following prompts, along with their example inputs, should be presented: Enter a course number: 1114 Enter a course name: Test Course Name Enter a course schedule (MWF or TR): MWF Enter course credit hours: 4 Enter student enrollment: 56 (b) From the terminal, read the following one line at a time: i. Course number (zero-indexed integer) ii. Course name (string possibly containing whitespace) iii. Course schedule (string ∈ {MWF,TR}) iv. Course credit hours (unsigned integer) v. Course enrollment (unsigned integer) (c) Using the values entered by the user, update the corresponding course record in the courses.dat file. (d) If the course already exists, print the following error and continue with the program. The program should detect this and respond immediately after reading the course number. ERROR: course already exists • U: update an existing course record Assignment 5: File I/O Page 2 of 6 (a) The following prompts, along with their example inputs, should be presented: Enter a course number: 1114 Enter a course name: New Course Name Enter a course schedule (MWF or TR): TR Enter course credit hours: Enter student enrollment: (b) Prompt the user for the following one at a time: i. Course number (zero-indexed integer) ii. Course name (string possibly containing whitespace) iii. Course schedule (string ∈ {MWF,TR}) iv. Course credit hours (unsigned integer) v. Course enrollment (unsigned integer) (c) Update each of the corresponding fields for the course based on the user’s input. If the user input is blank for a particular field (except course number), maintain the original value from the file. (d) If the course record is not found, print the following error and continue with the program. You should detect this and respond immediately after reading the course number. ERROR: course not found • R: read an existing course’s information (a) Prompt the user for a course number: (e.g., “3424”) Enter a course number: (b) Search for the specified course using the provided course number (e.g., “3424”). (c) Print the course information in the following format: Course number: course number Course name: name Scheduled days: schedule Credit hours: hours Enrolled Students: size (d) If the course is not found, print the following error instead and continue with the program. ERROR: course not found • D: delete an existing course (a) Prompt the user for a course number (e.g., “3424”): Enter a course number: (b) Delete the specified course’s record. Hint: You may assume thecreditHours field will never be zero for a valid course. Assignment 5: File I/O Page 3 of 6 (c) Print the following message to standard output with the course’s number: course number was successfully deleted. (d) If the course is not found, print the following error instead and continue with the program. ERROR: course not found • If an invalid character is entered, print the following error and continue with the program. ERROR: invalid option 4. After an action is completed, display the menu again. This should proceed indefinitely until CTRL-D is read, or the end of the file is reached. Locating Data For the above functionality, courses.dat should not be read sequentially to search for courses. The location of the course in courses.dat should be calculated immediately and directly accessed without performing a search (i.e., no looping!). Assignment Data Input files for testing can be found in /usr/local/courses/ssilvestro/cs3424/Spring21/assign5 including an existing .dat file and input for stdin. Copy these to your own assignment’s directory. Among these files you will also find courses.dat.output; this is the modified data file corresponding to the changes specified via the a5Input.txt input file. Additionally, a5Init.txt is provided, which can also be used to test your program; this file contains the input necessary to create the provided course data file from scratch. This “homemade” copy of the course data file can then be compared to the one provided and checked for accuracy. Important: The input file assumes you are using the provided .dat file. Furthermore, each time you use the input file, you should refresh the .dat file to its original state. Compiling Your Program Your submission will include a Makefile so the following command can be used to compile your code. $ make assign5 Program Files Your program should consist of up to three files: • assign5.c - the main file which is compiled (required) • assign5.h - an optional header file, if necessary • Makefile - the Makefile to make the assign5 executable (required) Assignment 5: File I/O Page 4 of 6 Verifying Your Program At a minimum, your program must work with the input provided in a5Input.txt and courses.dat. To test it: 1. Place courses.dat in the same directory as your compiled program. 2. Execute your compiled program and redirect a5Input.txt into it. You should not be copying or typing the contents of a5Input.txt into your terminal. Redirection must work. 3. Verify that the output is correct based on the input commands. 4. Execute your program again and use your program’s menu to test that the information was correctly written to courses.dat. Note: this constitutes a bare-minimum function test of your assignment, and your code is expected to work for any combination of validly-formatted data files and input command sequences. These files will not be utilized in the grading of your assignment. Extra Credit (25 pts) Implement an extra menu item that will perform a search on all course records in the courses.dat data file. This function should be accessed via the "F" menu option, and should prompt the user for a phrase that will then be used to search and compare against all data records’ fields. The search should be performed without case sensitivity. If a match is found, the course number should be printed, as well as the matching fields’ data. Below are two hypothetical examples demonstrating the proper usage (i.e. input and output formatting) of this optional command: F Enter a search phrase: Systems 3424: "Systems Programming" 4893: "Advanced Systems Programming" F Enter a search phrase: TH 3592: "TH" 1713: "TH" 2322: "TH" Submission Turn in your assignment via Blackboard. Your zip file, named a5-abc123.zip should contain only your Makefile, assign5.c, and possibly assign5.h. Assignment 5: File I/O Page 5 of 6 If you attempt the extra credit, name your file a5-abc123_EC.zip. Without the _EC, your submission will be graded as normal. Do not include a .dat file. Assignment 5: File I/O Page 6 of 6

Related Questions

Similar orders to Assignment 5: File I/O course catalog database
5
Views
0
Answers
Creating a DNS server (written in C)
WANT >=50% due to being swamped (only standard option minimal, don't care about cache or non-blocking). I require periodic updates of code with a description as there is a Git commit tracking. Also require a makefile according to the specifications and a g...
20
Views
0
Answers
Create inheritance project for a restaurant
Projects must include: -at least three different levels of inheritance - at least nine classes total -the highest superclass must have at least two methods -every subclass must contain a unique method that was not present in its super...
16
Views
0
Answers
Python Code for Suggesting Pets
Must have ___init___ ; ___str___ ; for loops ; while loops ; and must define a function which returns something, I wrote down what idea I had in that form so its best to follow it, this is an entry-level computer science project so it should be pretty easy...
22
Views
0
Answers
Quick HW Computer Science on LL(1) and object creation
Due at 12:00pm today. The question details are in the files attached. One question is on the impact of a parser being LL(1) or not. Another is on imagining a mistake in object creation. The answers are probably max 2 lines long....