Project #3
(Due 23 February 2005)
You are to write a program to help automate an ice cream parlor. Customers are expected to order ice cream using three-word phrases that they type in themselves at the order kiosk. Note: the keyboard in the kiosk contains only lowercase letters. The first word in an order must be the amount of ice cream being ordered, measured in scoops. So, the first word must be "single", "double", or "triple" or some valid prefix abbreviation of these words. The second word in an order must be the flavor which must be written as one word (hyphenated if necessary) and may be abbreviated - for example, "strawberry", "choc", and "fudge-ripple" are all valid flavors. The flavor must have at least 4 characters. The third word is the form and must be either "cone" or "bowl" or some valid prefix abbreviation of these words. Here are a few complete examples:
single mint-chocolate-chip bowl
Single scoop of mint chocolate chip in a bowl
t choc c
Triple scoop of chocolate in a cone
dou cookie cone
Double scoop of cookie dough in a cone
The price for an ice cream order depends on the amount and the form and is based on a single scoop in a cone ($1.49) or a bowl ($1.29). A double costs 180% of a single; and a triple costs 240% of a single. The flavor does not matter in calculating the price.
Your program should prompt the customer for an order. After the customer enters the three-word order, the program must determine what was ordered and figure out its price. If the program detects that the customer has entered something invalid like "single van dish", it must tell the customer that the order is invalid and request reentry of the order. If the order is valid, the program should ask the customer if s/he wants sprinkles added to the ice cream. The customer is allowed to enter anything ("yes", "y", "yo" "yeah") that begins with a 'y' to indicate "yes". Sprinkles cost $0.10 for a single and increase just as the price of ice cream does - 180% for double, 240% for triple.
The customer's answer to the sprinkles question completes the order of one item for the customer. The program should then display the complete item order and the total cost of that item (and note that tax will be added). This display should show the full name for the amount and form; for example, if the customer entered t choc c the display should show triple choc cone The program is not expected to know all the flavor abbreviations; but it must be able to recognize that t means triple and that c means cone. The program should then prompt the customer for another order. The customer can then enter a three-word order of another item to be added to the total. If the customer does not have anything more to order, s/he should enter the word "done".
When the customer enters "done", the program should display the total price for everything the customer ordered. The total price will include 6% sales tax on the complete order that must be added in to the total. Note: when calculating taxes, any fraction of a cent is to be counted as an extra cent.
Hand in a print out of your program and the captured execution output in which a customer enters the following order:
double peach bowl
and asks for sprinkles
si rocky c
and asks for sprinkles
single vani bo
and does not want sprinkles
quad butter-pecan cone
should be an error
trip cherry-swirl bow
and does not want sprinkles
triple chocolate-marshmallow cone
and asks for sprinkles
double cone vanilla
should be an error
done
Also, copy the .cpp source file to the
handin folder on the P: drive. Be sure to name the source file
after yourself before copying it to the P: drive.