Description
Seneca Groceries
This question is designed to be done
by a group of 1-3 students. Submissions from groups of more than 3 students
will not be accepted and all group members will receive zero for this portion
of the assessment. Each group member must write and submit their own
reflections which will be different from the reflections from other group
members. Only 1 member of the group has to submit the code and every file must
have a comment at the top identifying all members of the group.
You have been asked to write a
program for a grocery store that will:
- Start by
allowing the entry of the current stock in the store, which it will save
and update during the day.
- Switch to
sales mode where it will act like a cash register and allow customers to
purchase things. It will update the inventory as items are sold and will
produce an itemized receipt for the
customer.
- At the end of the day, print a summary of
the sales, the inventory remaining and the top sellers in each category.
Products for sale are identified by
name, and are placed in a category and the category is entered by its number:
- produce
- bakery
- meat
- dairy
- baking
- house wares
- miscellaneous
Each item has a price and an
indication of whether it is sold per unit or by weight which is entered as 0 if
sold by the number purchased or 1 if sold by weight. It also indicates how much
we have of this item either in units or by weight rounded down to the nearest
kilogram.
When we sell items, they are sold by
weight in fractional Kg or by integral unit counts. When the final amounts in
inventory are calculated, they are rounded down to the nearest Kg for items
sold by weight. If a customer tries to purchase more of something than we have
in stock, we sell only the amount we have in stock. Most groceries are tax free
except items in the house wares and miscellaneous categories which are taxed at
13%.
The list of items being purchased is
terminated by an item with the ID of 0. A sale with no items added to it marks
the end of sales which should be followed by the summary of the day’s sales.
Input data should be checked for
correct category range (1-7), sold by weight range (0-1). As the stock is
entered, each item is assigned a numeric identifier from 1 upwards in the order
the items are entered. For stock entry, you can assume that each item is only
entered once.
When purchasing, the customer will
identify the product to purchase by the identifier assigned to it when it
was entered in the stock and listed in the initial stock report in the ID
column. These product ID number should be checked to ensure that they are
valid.
Below this section you will find:
- main.c which
is the main for the program. You must use this main.c for your program
without changes. This means that you will need to implement the data
structures it uses and the functions it uses in the files stock.h and
stock.c. You SHOULD create additional functions, other than the ones
called from main, to create a highly modular, well-designed program. Your
code will be tested against this main.c and your code must work and
produce the expected output.
- A sample
execution of the program to which your program’s output should look very
similar.
- Sample data
which can be cut and pasted into the program for final testing. This is
the data which generated the sample output.
You are required to:
- In a group of
1, 2 or 3 people create the missing code and have 1 group member submit
the files stock.h and stock.c as a zip file. (Groups attempting the bonus
question must also include main.c if they modified it) Submission from groups
of more than 3 people will not be accepted and all members of these groups
will receive 0 for this portion of the final assessment.
- Place a
comment at the top of both stock.h and stock.c listing the names of every
member of the group.
- Individually
write a reflection based on the questions below and submit it on
Blackboard. This means that a group of 3 students will need to submit 3
different reflections.
- BONUS: (5%) if
you read the existing stock from a file containing the test data with the
errors fixed. You will need to correct the errors in the data and place it
in a file. Then, you can read it from the file without the error checking
that is done with the manually typed version. You can change the value of
the constant STOCK_FROM_STDIN declared
in main to allow you to read from a file. Note that the sales will
continue to be read from stdin, it is only the initial stock which will be
read from the file. This will change the output to show the initial prompt
for stock followed immediately the summary of the opening stock. The
typing of the stock will vanish as it is being read from a file.