Perl Programming Assignment #4
COSC 146
We'll update the features to the "Time to Eat" program (see program 3)
The program should present the same interface to the user. However, the
final bill presented to the user
will look different. We imagine the following dialog with the menu
system. The user will order 2
hamburgers and 1 large Coke:
EMU Gourmet Food
1) Hamburger 3.49
2) Frankfurter 2.19
3) French Fries 1.69
4) Large Coke 1.79
5) Medium Coke 1.59
6) Small Coke 1.39
7) Onion Rings 1.19
8) Tally Bill and Start over
9) Stop
Enter selection : 1
EMU Gourmet Food
1) Hamburger 3.49
2) Frankfurter 2.19
3) French Fries 1.69
4) Large Coke 1.79
5) Medium Coke 1.59
6) Small Coke 1.39
7) Onion Rings 1.19
8) Tally Bill and Start over
9) Stop
Enter selection : 4
EMU Gourmet Food
1) Hamburger 3.49
2) Frankfurter 2.19
3) French Fries 1.69
4) Large Coke 1.79
5) Medium Coke 1.59
6) Small Coke 1.39
7) Onion Rings 1.19
8) Tally Bill and Start over
9) Stop
Enter selection : 1
EMU Gourmet Food
1) Hamburger 3.49
2) Frankfurter 2.19
3) French Fries 1.69
4) Large Coke 1.79
5) Medium Coke 1.59
6) Small Coke 1.39
7) Onion Rings 1.19
8) Tally Bill and Start over
9) Stop
Enter selection : 8
Qty
Desc. Unit $
Total
2
Hamburger
3.49 6.98
1
Large Coke
1.79 1.79
-------------------------------------------------
Total
8.77
EMU Gourmet Food
1) Hamburger 3.49
2) Frankfurter 2.19
3) French Fries 1.69
4) Large Coke 1.79
5) Medium Coke 1.59
6) Small Coke 1.39
7) Onion Rings 1.19
8) Tally Bill and Start over
9) Stop
Enter selection :
Requirements for your assignment:
1) You must use arrays! Suggestions: have one array to hold the
description of the items ("Hamburger", "Frankfurter",etc. and another
parallel array to hold the
corresponding prices (3.49,2.19, etc.) Finally, have one more array
called @quantity where each entry is initilized to 0.
$quantity[0] represents the number of hamburgers ordered,
$quantity[1] represents the number of frankfurters ordered, etc. When
the user enters an 8, just multiple non-zero entries of @quantity times
the corresponding price.
2) You must use a subroutine to display the menu and get the user
response. The user response will be used back in the main program.
PLEASE NOTE: Part of your grade (a major part) will be based on your
ability to get your program to look like the sample given here. Pay
particular attention
to how the bill looks when printed out. You will need to use printf
statements. Note that the headings "Qty" , "Unit $", and "Total" have
widths of 10 characters, while
"Desc." has a width of 12. Also note that the total (8.88 in this case)
lines up with the "Total" column.