Fair Time
Due: Friday, Oct. 13, 8am
6 points
Change
into your cps6 directory using the
In order to do this assignment, you need to copy some files using the
following
If you type ls you should see the following files: Makefile, fair.cc, glassware, and leather. To compile your program, just type: make fair
It's the season for craft fairs. Your assignment is to help the crafters in determining which of their items are most profitable. Every crafter keeps a record of each item sold and the price it sold for. You are to write a generic program in which any crafter can find out specific information on a particular item.
Each crafter has a data file in which each line represents an item sold. The format of a line is the name of the item, the size of the item (small or large) and the price the item sold for. For example, in the data file below, 6 items were sold.
coat small 140.00 coat large 199.99 coat small 140.00 coat large 199.99 purse small 27.80 coat small 120.00
There are two data files you can use to test your program. The file leather contains the items coat, belt, wallet, and purse, all in small and large sizes. The file glassware contains the items mobile, platter, bowl, and mirror, all in small and large sizes.
Use standard I/O for the text shown in the sample runs, and use a file stream to read data stored in a craft data file.
Your program should ask the crafter for the name of a specific item, the size of the item (small or large), the cost to make the item and the name of the data file containing the list of items sold.
You should print the following information.
> fair Enter an inventory item: coat Enter size of item (large or small): small Enter cost of item: 61.50 Enter name of inventory file: leather The small coat was 27.81 percent of the items sold and 52.11 percent of the total amount of money collected. Its average selling price was $131.90 Total profit on this item was $2957.00 > fair Enter an inventory item: mirror Enter size of item (large or small): large Enter cost of item: 26.60 Enter name of inventory file: glassware The large mirror was 14.05 percent of the items sold and 24.90 percent of the total amount of money collected. Its average selling price was $42.75 Total profit on this item was $274.55 >
Once you have completed fair.cc, make a copy of it called fair2.cc.
Modify fair2.cc in the following way. Each crafter makes exactly
> fair2 Enter an inventory item: blouse Enter size of item (large or small): large Enter cost of item: 16.60 Enter name of inventory file: clothes The item blouse is not made by this crafter. Items made include shirt, dress, pants and socks. >
When your program works correctly, create a README file containing your name, the date, and an estimate of how long you worked on the assignment. You must also include a list of names of all those people with whom you collaborated on the assignment.
To submit your programs electronically type
submit6 assign4 README fair.cc
You should receive a message telling you that the programs were submitted correctly. If it doesn't work try typing ~ola/bin/submit6 in place of submit6 above.
If you do the extra credit, you must also submit the file fair2.cc. Include it at the end of the submit6 command. That is, type
submit6 assign4 README fair.cc fair2.cc