CMSC 201
Programming Project One
B & E Catering
Out: Tuesday 2/25/03
Due Date: before midnight, Wednesday 3/5/03
|
The Objective
The objective of this assignment is to get you familiar with good design
practices, writing in C in a Unix environment, and using functions.
The Background
Ms. Block and Mrs. Evans have just started a morning snack catering
business called B & E Catering Company. The company caters to groups of 8 to
1000 and offers either doughnuts or mini-muffins.
Research was done by the company before opening to make filling customers'
orders as simple as possible for both the clerk and the customer. When a
customer calls, they need only specify the number of guests expected and
whether they would like doughnuts or mini-muffins to be served.
The Task
You have been hired by "B & E Catering" to write a program that allows
a clerk to give customers price quotes over the phone. Since the clerk may
receive one request for quotation after another the program should process
quote after quote until the clerk decides to quit the program. Your program
should be menu-driven, asking the clerk to choose to price a doughnut order,
a muffin order, or to quit the program.
You will find the following information useful. Research has shown that :
- Doughnuts:
- the average doughnut consumption is 1 1/2 doughnuts per person
- the two most popular doughnuts are chocolate covered and glazed
- chocolate covered doughnuts are prefered two to one over glazed
- the current price of a dozen doughnuts is $7.99
- Mini-muffins:
- the average mini-muffin consumption is 2 1/2 muffins per person
- the three most popular muffins are banana-nut, orange-cranberry,
and lemon-poppyseed
- banana-nut muffins are prefered two to one over the other kinds
- orange-cranberry and lemon-poppyseed muffins are equally well liked
- the current price of a dozen mini-muffins is $6.99
You MUST use constants (#define) for each of the consumption
rates shown above, as well as the current prices of both doughnuts and mini-
muffins. You must use constants for your menu choices, the number of items in
a dozen, minimum and maximum valid entries from the menu, minimum and maximum
valid entries for the number of guests being served, and for the current state
sales tax rate.
Your program MUST include the following functions. Do
NOT change the function prototypes given below. You may
choose to use more functions if you wish, but these are sufficient.
- void PrintGreeting (void); -- displays a suitable greeting to the
user
- void DisplayMenu (void); -- displays the main menu choices
- int GetMenuResponse (int min, int max); -- gets an integer from the
user between min and max, inclusive and returns that valid integer as the menu
choice.
- float OrderDonuts (float price); -- a high level function that
completely handles placing an order for doughnuts and returns the subtotal
(total before tax) for the order.
- float OrderMuffins (float price); -- a high level function that
completely handles placing an order for mini-muffins and returns the subtotal
(total before tax) for the order.
- int FindDozens (int people, float rate); -- calculates and returns
the number of dozens needed using the number of people and their rate of
consumption.
- int GetNumPeople (int min, int max); -- gets the number of people
from the user guaranteeing the number is within the range of min and max,
inclusive and returns that number.
- float CalculateTax (float subtotal, float rate); -- calculates the
amount of tax to be charged from the subtotal and the tax rate passed in.
- void PrintTotals (float subtotal, float tax, float total); --
prints the subtotal, tax amount, and the total on the bottom of every order.
More Details
- After getting the number of people and the type of order (doughnut or
muffin), your program should calculate the number of doughnuts or muffins
needed using the consumption rates shown above. You should ignore
fractional parts of doughnuts or muffins. For instance, if the order
is for doughnuts for 35 people, that would be 52 1/2 doughnuts. You
should consider this to be 52 doughnuts.
- B & E will supply only full dozens of doughnuts or muffins. If there
are 1 or 2 individual doughnuts or muffins needed over and above some
number of dozens, they should be ignored. However, if 3 or more
individual doughnuts or muffins are needed, another full dozen
should be supplied. For example, if 25 or 26 items are needed
then only 2 dozen would be supplied. If 27 items are needed
then 3 dozen would be supplied.
- Doughnuts are always supplied in the ratio 2 chocolate covered
to 1 glazed. So, if 1 dozen doughnuts were necessary, it
would be a mixed dozen comprised of 8 chocolate covered and
4 glazed. If 3 dozen were needed, there would be 2 dozen
chocolate covered and 1 dozen glazed delivered, etc.
- Mini-muffins are always supplied in the ratio 2
banana-nut to 1 orange-cranberry and 1 lemon-poppyseed. So,
if 1 dozen were needed, it would be a mixed dozen comprised
of 6 banana-nut, 3 orange-cranberry and 3 lemon-poppyseed.
If 4 dozen were needed, there would be 2 dozen banana-nut,
1 dozen orange-cranberry and 1 dozen lemon-poppyseed delivered,
etc.
Additional Specifications
- You must use a switch statement for menu selection
- Decimal points must be aligned in the output
- You must limit the number of mixed dozens to 1, with the following
exception:
There are some numbers of guests that will cause 2 dozen mixed muffins
to be needed. In those cases, you may have 2 dozen mixed muffins.
Sample Run
linux1[101] gcc -Wall -ansi proj1.c
linux1[102] a.out
Your greeting goes here
1 - Order Doughnuts
2 - Order Muffins
3 - QUIT
Please enter your menu choice : 1
Please enter the number of guests : 8
------------------------------------------------------------------------------
Doughnut order for 8 people
1 dozen Mixed doughnuts at $7.99/dozen 7.99
Comprised of :
8 chocolate covered & 4 glazed
----------------------
Subtotal 7.99
Tax 0.40
----------------------
Total 8.39
----------------------
------------------------------------------------------------------------------
1 - Order Doughnuts
2 - Order Muffins
3 - QUIT
Please enter your menu choice : 1
Please enter the number of guests : 16
------------------------------------------------------------------------------
Doughnut order for 16 people
1 dozen Chocolate covered doughnuts at $7.99/dozen 7.99
1 dozen Mixed doughnuts at $7.99/dozen 7.99
Comprised of :
4 chocolate covered & 8 glazed
----------------------
Subtotal 15.98
Tax 0.80
----------------------
Total 16.78
----------------------
------------------------------------------------------------------------------
1 - Order Doughnuts
2 - Order Muffins
3 - QUIT
Please enter your menu choice : 1
Please enter the number of guests : 25
------------------------------------------------------------------------------
Doughnut order for 25 people
2 dozen Chocolate covered doughnuts at $7.99/dozen 15.98
1 dozen Glazed doughnuts at $7.99/dozen 7.99
----------------------
Subtotal 23.97
Tax 1.20
----------------------
Total 25.17
----------------------
------------------------------------------------------------------------------
1 - Order Doughnuts
2 - Order Muffins
3 - QUIT
Please enter your menu choice : 1
Please enter the number of guests : 26
------------------------------------------------------------------------------
Doughnut order for 26 people
2 dozen Chocolate covered doughnuts at $7.99/dozen 15.98
1 dozen Glazed doughnuts at $7.99/dozen 7.99
1 dozen Mixed doughnuts at $7.99/dozen 7.99
Comprised of :
8 chocolate covered & 4 glazed
----------------------
Subtotal 31.96
Tax 1.60
----------------------
Total 33.56
----------------------
------------------------------------------------------------------------------
1 - Order Doughnuts
2 - Order Muffins
3 - QUIT
Please enter your menu choice : 1
Please enter the number of guests : 35
------------------------------------------------------------------------------
Doughnut order for 35 people
3 dozen Chocolate covered doughnuts at $7.99/dozen 23.97
1 dozen Glazed doughnuts at $7.99/dozen 7.99
1 dozen Mixed doughnuts at $7.99/dozen 7.99
Comprised of :
4 chocolate covered & 8 glazed
----------------------
Subtotal 39.95
Tax 2.00
----------------------
Total 41.95
----------------------
------------------------------------------------------------------------------
1 - Order Doughnuts
2 - Order Muffins
3 - QUIT
Please enter your menu choice : 1
Please enter the number of guests : 1001
We can only place orders for 8 to 1000 guests
Please enter the number of guests : 7
We can only place orders for 8 to 1000 guests
Please enter the number of guests : -2
We can only place orders for 8 to 1000 guests
Please enter the number of guests : 0
We can only place orders for 8 to 1000 guests
Please enter the number of guests : 1000
------------------------------------------------------------------------------
Doughnut order for 1000 people
83 dozen Chocolate covered doughnuts at $7.99/dozen 663.17
41 dozen Glazed doughnuts at $7.99/dozen 327.59
1 dozen Mixed doughnuts at $7.99/dozen 7.99
Comprised of :
4 chocolate covered & 8 glazed
----------------------
Subtotal 998.75
Tax 49.94
----------------------
Total 1048.69
----------------------
------------------------------------------------------------------------------
1 - Order Doughnuts
2 - Order Muffins
3 - QUIT
Please enter your menu choice : 2
Please enter the number of guests : 8
------------------------------------------------------------------------------
Mini-Muffin order for 8 people
1 dozen Banana Nut Muffins at $6.99/dozen 6.99
1 dozen Mixed Muffins at $6.99/dozen 6.99
Comprised of :
6 cranberry orange & 6 lemon poppyseed
----------------------
Subtotal 13.98
Tax 0.70
----------------------
Total 14.68
----------------------
------------------------------------------------------------------------------
1 - Order Doughnuts
2 - Order Muffins
3 - QUIT
Please enter your menu choice : 2
Please enter the number of guests : 20
------------------------------------------------------------------------------
Mini-Muffin order for 20 people
2 dozen Banana Nut Muffins at $6.99/dozen 13.98
1 dozen Cranberry Orange Muffins at $6.99/dozen 6.99
1 dozen Lemon Poppyseed Muffins at $6.99/dozen 6.99
----------------------
Subtotal 27.96
Tax 1.40
----------------------
Total 29.36
----------------------
------------------------------------------------------------------------------
1 - Order Doughnuts
2 - Order Muffins
3 - QUIT
Please enter your menu choice : 2
Please enter the number of guests : 21
------------------------------------------------------------------------------
Mini-Muffin order for 21 people
2 dozen Banana Nut Muffins at $6.99/dozen 13.98
1 dozen Cranberry Orange Muffins at $6.99/dozen 6.99
1 dozen Lemon Poppyseed Muffins at $6.99/dozen 6.99
1 dozen Mixed Muffins at $6.99/dozen 6.99
Comprised of :
6 banana nut, 3 cranberry orange & 3 lemon poppyseed
----------------------
Subtotal 34.95
Tax 1.75
----------------------
Total 36.70
----------------------
------------------------------------------------------------------------------
1 - Order Doughnuts
2 - Order Muffins
3 - QUIT
Please enter your menu choice : 2
Please enter the number of guests : 101
------------------------------------------------------------------------------
Mini-Muffin order for 101 people
10 dozen Banana Nut Muffins at $6.99/dozen 69.90
5 dozen Cranberry Orange Muffins at $6.99/dozen 34.95
5 dozen Lemon Poppyseed Muffins at $6.99/dozen 34.95
1 dozen Mixed Muffins at $6.99/dozen 6.99
Comprised of :
6 banana nut, 3 cranberry orange & 3 lemon poppyseed
----------------------
Subtotal 146.79
Tax 7.34
----------------------
Total 154.13
----------------------
------------------------------------------------------------------------------
1 - Order Doughnuts
2 - Order Muffins
3 - QUIT
Please enter your menu choice : 2
Please enter the number of guests : 102
------------------------------------------------------------------------------
Mini-Muffin order for 102 people
11 dozen Banana Nut Muffins at $6.99/dozen 76.89
5 dozen Cranberry Orange Muffins at $6.99/dozen 34.95
5 dozen Lemon Poppyseed Muffins at $6.99/dozen 34.95
1 dozen Mixed Muffins at $6.99/dozen 6.99
Comprised of :
6 cranberry orange & 6 lemon poppyseed
----------------------
Subtotal 153.78
Tax 7.69
----------------------
Total 161.47
----------------------
------------------------------------------------------------------------------
1 - Order Doughnuts
2 - Order Muffins
3 - QUIT
Please enter your menu choice : 2
Please enter the number of guests : 1000
------------------------------------------------------------------------------
Mini-Muffin order for 1000 people
104 dozen Banana Nut Muffins at $6.99/dozen 726.96
52 dozen Cranberry Orange Muffins at $6.99/dozen 363.48
52 dozen Lemon Poppyseed Muffins at $6.99/dozen 363.48
1 dozen Mixed Muffins at $6.99/dozen 6.99
Comprised of :
6 banana nut, 3 cranberry orange & 3 lemon poppyseed
----------------------
Subtotal 1460.91
Tax 73.05
----------------------
Total 1533.96
----------------------
------------------------------------------------------------------------------
1 - Order Doughnuts
2 - Order Muffins
3 - QUIT
Please enter your menu choice : 4
Please try again.
Valid choices are between 1 and 3 : 0
Please try again.
Valid choices are between 1 and 3 : -5
Please try again.
Valid choices are between 1 and 3 : 3
Closing Ordering Program
linux1[103]
Although your output need not be identical to the above,
all information (including the greeting) must be present.
Submitting the Program
You must name your source file proj1.c
To submit your project, type the following at the Unix prompt:
submit cs201 Proj1 proj1.c
To verify that your project was submitted, you can execute the
following command at the Unix prompt. It will show all files that
you submitted in a format similar to the Unix 'ls' command.
submitls cs201 Proj1