In this homework you'll write a parser which is capable of taking in a CSV (Comma Separated Value) file of a restaurant menu and providing some information about that menu. The name of the program will be menu, its first argument will be the file to read from, its second argument will be the file to write output to, and the third argument (if present) specifies a target meal cost.
The program will take input from a file specified as the first command line argument. The input to the program will be of the following form, with one line per menu item:
Item Name, Item Price, Item Category
The item name will be some combination of letters and symbols (except for ',' and '\n'). These strings may be of any length. All symbols should be stripped from the item names, you need only store the letters.
The item price will be a '$' followed by any number of digits, a '.' and more digits. Each part of the number (before and after the '.') will be less than or equal to the maximum possible unsigned integer. For example, these are valid prices:
The item category is an integer describing whether this item is an appetizer (1), an entre (2), or a dessert (3). A full meal consists of one of each of these.
Here is an example of one piece of valid input into the program: sample1.in
The goal of this assignment is to print some interesting information to the output file specified as the second command line argument. The information is: the names of the items that make up the cheapest available complete meal (appetizer, entre, and dessert), the names of the items that make up the most expensive available complete meal, and (if a third argument was supplied) the names of the items that make up the complete meal that comes closest in price to the price specified by the third command line argument (in the same format as the "Item Price" described above, but without the dollar sign). The output must be in the following tab-separated format to the file specified on the command line:
Cheapest Appetizer: Item Name Entre: Item Name Dessert: Item Name Most Expensive Appetizer: Item Name Entre: Item Name Dessert: Item Name Closest Appetizer: Item Name Entre: Item Name Dessert: Item Name
Format of the output must be precise, there must be a header the same as the one specified above. Note, the last four lines would not be output if no third command line argument was given. For clarity, if you had the previous three lines as format strings (think octal dump) they would be as follows:
Cheapest\n Appetizer:\tItem Name\n Entre:\tItem Name\n Dessert:\tItem Name\n Most Expensive\n Appetizer:\tItem Name\n Entre:\tItem Name\n Dessert:\tItem Name\n Closest\n Appetizer:\tItem Name\n Entre:\tItem Name\n Dessert:\tItem Name\n
Here is the output your program should produce when given the above example input, and run like this: menu sample1.in sample1.out 50.00
You may want to copy the sample input and output from ~cs61c/public_html/su06/hw/hw3/ to your account space so that you can compare the output of your program to the proper output.
You may assume the following:
Submit any number of files by creating a directory called hw3 with all your source files in it, as well as a Makefile. From within this directory run "submit hw3". Be certain that your program formats its output according to the specifications. You may wish to use the unix diff command (man diff for more info) to compare your output to the example output. For more info on Makefiles, consult The GNU Make Manual. From within your hw3 directory, one should only have to type make ; ./menu <infile> <outfile> <optional price> on nova.cs to compile and run your program. We encourage you to split your code up into logical blocks in separate files.