Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You will be using functions, Cstrings and structs to build a menu driven program for a media collection. We wont be working with File IO

You will be using functions, Cstrings and structs to build a menu driven program for a media collection. We wont be working with File IO in this project.

What To Code

Write a menu-driven program for a user to store information about the media collection they own. This requires using an array of struct type called Media. Every element in the array represents one media item in a person's collection. Represent the information as an array of structs that needs to able to hold up to 100 media entries. However, the actual number of entries is probably much smaller so the program needs to keep track of how many actual entries are in the collection.

A Media struct

Each media item has an unique ID, category, title, year and a description. The title and description wont be any larger than 250 characters so you can make C-strings of that size. You must use C-strings for these fields; so string type allowed. Year and ID number are integers. Acceptable category values would be 'video', 'printed' and 'audio' and any other media categories you might want to add. NOTE: although not a requirement, the category can be made into an enum type but you can also just use a set of C-strings as well.

User Actions

The user should be able to do the following:

Add a media item to the collection Ask the user for the information. Make sure the category is a valid value and that the year is not negative. You can either set the ID to an unique number OR you can let the user type in an ID but make sure the user types in an ID that's unique.

Print all media in the collection Keep in mind that this should not print any blank entries in your array. Print all media in a given category Print out all entries with the given category. Shouldnt print any other entries from other categories.

Delete an entry - Ask for an ID number (you can print out the list for the user). Then delete this entry from the array. NOTE: The best way to do this is to move entries over one. Another way, which is more complex, is to put a 'marker' value in one of the fields (ID or title) to indicate that this entry is deleted and then skip over this entry when searching and printing.

Functions

You need to use functions in this project. They should be called at some point in your code and should do something useful. Keep in mind that all functions, including main, must be less than 30 lines long. Lines means any line of actual code so it excludes blank lines, lines with only braces and comment lines.

HINT: The above list of tasks should all be inside functions. Reading in from the file and writing out to the file should also be inside functions. You might also want to make a printEntry function that takes an index into the array and prints out all the media information at that index. This can be used in several different functions. Also, a findEntry might also be useful: takes a media ID, searches for it and returns the index of where the ID was found (pass back a -1 if the ID is not found). This can be used in adding the entry to verify that the ID is not in the list (is unique).

Requirements

The tasks as listed above should be available for the user choose and should work as described. You can add other tasks and features but I will be only grading you on the above tasks so make sure these work before you add other things. You must create and use a Media struct; other structs are optional. You must have enough functions in your program to keep all of them under 30 lines long. Again, all functions should be called at some point in your program and do some work. All functions, including main, must be less than 30 lines long (this count does not include comments, blank lines and { } on separate lines). You need to use C-strings, no 'string' type in your entire code. You can keep constants at the global level but no variables are allowed to be global. So pass the collection array and entry count into functions along with any other variables. If you need to change a variable, please remember to pass it in by reference ( put '&' in front of parameter name). There should be one and only one array in your file; you will get points off if you have any other arrays in your file OR are missing an array.

NOTE: It might be easier to do debugging if you put a few entries into the array ahead of time so you dont have to keep typing them in for testing your program. You can also leave them in but I should be able to add or delete to the array when I grade your project.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Peter Rob, Carlos Coronel

3rd Edition

0760049041, 978-0760049044

More Books

Students also viewed these Databases questions