The objectiveof this problem is to implement in a C program a simple database that might be helpful in assigning the grades in ECE15. Specifically, the program should be able to store, retrieve, and manage student records, which contain the following information: student names, their account ID’s, and their grades forthelabs, midterm, andfinal. Thefunctionalityofthedatabaseshouldallowtheuserto search, add, and delete such records. In addition, it should be possible to produce various statistics, such as the histogram of grades. Your task is to write a C program, called gradebook.c, which implements this functionality. The program input and output are described in detail in what follows.

When invoked, the program should first initialize the database by reading student records from the text file called gradebook.dat. A sample gradebook.dat file is shown below: See image.

Each line of this file corresponds to a student record, and consists of six fields: the two-character ac- count ID, the first name and the last name of the student, each at most 16 characters, and three integer grades for labs, midterm, and final. The fields are separated by whitespace. The ZZ account ID does not correspond to an actual student record; instead, it is reserved to signify the end of the input.

After initializing the database from the file gradebook.dat, the program should print to the screen the following welcome message: See image.

Note that each line of*in the welcome message consists of 64 characters. After printing the welcome message, the program waits for the user to select one of the six options: a, d, k, p, s, q.

If the user enters anything other than one of the six ASCII characters a, d, k, p, s, q, the program should inform the user that an invalid option was chosen, and ask the user to try again. If the user enters the character q, the program should simply terminate, without producing any additional output. Here is a sample run, wherein the user input is shown in red. See image.

The program shouldcontinueto run in a loop untiloptionq is chosen. Therequired behaviorof thepro- gram when the user chooses one of the five valid options a, d, k, p, s is described in detail below.

Printing the records: If the user enters p at the Option prompt, the program should print to the screen (stdout) all the records currently in the database, in the format shown below, and then prompt the user to enter another option key. The order in which the records are printed in not important. Here is a sample run, assuming the current state of the database exactly matches the file gradebook.dat. See image.

Reporting grade statistics: If the user enters s at the Option prompt, the program should com- pute the grades for all the students, and then display the pertinent grade statistics in the format shown below. Here is a sample run, assuming the database exactly matches the file gradebook.dat. See image.

Specifically, the grades are computed according to the formula 0.3*Lab + 0.2*Mid + 0.5*Fin. Thus the grades for the seven students in the file gradebook.dat are 82.2, 85.3, 64.6, 85.1, 50.0, 50.0, and 43.2, respectively. The statistics reported are the mean grade, the highest grade, and the his- togram of the grades. In the histogram, each grade is represented by a single #. The line labeled 0-10 corresponds to grades in the range [0,10.9], the line labeled 11-20 corresponds to grades in the range [11.0,20.9], and so on. You may assume that all the grades are always in the range [0,100].

Keyword search: If the user enters k at the Option prompt, the program should ask the user to enter a keyword(string)to search for. Subsequently, it should displayall the records in thedatabase that contain that keyword (anywhere in the record), if any are found. Several sample runs are shown below. See image.

Deleting a record: If the user enters d at the Option prompt, the program should ask the user to enter an account ID and, if this account ID is valid, display the corresponding record before deleting it from the database. If the account ID is not valid, the program should inform the user that there is no such record. Here are several sample runs, assuming the database in the file gradebook.dat. See image.

Adding a record: If the user enters a at the Option prompt, the program should ask the user to en- ter a new record, as shown below. If the user correctly enters a new record (account ID, first name, last name, and three integer grades in the range [0,100], all separated by whitespace) and there is no record in the database with the same account ID, the program should add the new record to the database, while informingthe user. If the userinput is invalid, the program should displayan appropriate message, keep the database unchanged, and prompt the user to enter a new option key. Finally, what happens if the user correctly enters a new record, but a record with this account ID already exists in the database? In this case, the program should ask the user whether the existing record should be overwritten. If the user respondswitheithery orY, theprogram shouldoverwritetheexistingrecord. In allothercases, thepro- gram should keep the database unchanged. Here are several sample runs, illustrating this functionality. See image.

The program should read its input from the user (stdin), in the format described in detail in the prob- lem specification above. The program should also read from the file gradebook.dat, consisting of two or more lines. Each line except the last corresponds to a student record, and consists of six fields separated by blanks. The first field is the account ID; it consists of two ASCII characters in the range [a–z]. The next two fields are the first name and the last name of the student, each consisting of at least one and at most 16 characters in the range [a–z]. The last three fields are integers in the range [0,100] representing the student’s grades for labs, midterm, and final. The last line in the file contains the two characters ZZ. A sample gradebook.dat file is shown on page 1 and below: See image.

You do not need to check the validity of the gradebook.dat file: you can assume that it conforms to the specifications above. You can also assume that the file contains at least 2 and at most 512 lines (that is, at least 1 and at most 511 records). In fact, you may further assume that the total number of records in the database, including records potentially added by the user, never exceeds 511.

The program should write its output to the screen (stdout). The format of the output for each of the five options a, d, k, p, s is described in the problem specification above. Notice that the header: See image.

consistsoftwo lines,each containing64 characters. Thereare4 blanksbetween Acct ID and First name, 8 blanks between First name and Last name, 9 blanks between Last name and Lab, 4 blanks between Lab and Mid, and 4 blanks between Mid and Fin.

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.