Programming Assignment #3
COSC 146

PLEASE NOTE: this assignment has been updated. There are now 2 programs to do.

Program 1:


Time to Eat !!!!!

This program will be an simple order entry system for a restaurant. We'll improve it in future assignments. The menu is below:

EMU Gormet 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 :

As long as the user enters numbers 1-7, the system will accumulate the total bil. If the user enters 8, the system will print out the total,
and then zero out the total in preparation for a new bill. For example, the following is a dialog where the user entered a 1, 2 and then asked for a bill total:

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 : 2

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
Your total bill is : $5.68 

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 : 

------------------------------------
A few things to note (and program requirements!)
- Entering an 8 prints out the current running total and then zeroes out the total. The program does not terminate until the user
enters a 9.
- Your program MUST use sprintf to format the output. Please note that there is exactly one space after the colon and before the dollar sign.
- Your program must print the dollar sign. I'll leave it to you to figure out how to do this.
- Your program must employ a do....while    or do... until loop

Program 2:
Complete the following program:

#!/usr/bin/perl


use strict;

my @firstName;
my @lastName;
my @studentID;
my @amountDue;
my $count=0;
my $temp;

do
{

    do               # what's this loop doing ????
    {
        print "\nEnter student id (0 to quit) ";
        $temp=<STDIN>;
        if ($temp<0)
        {
            print "\n\nID must be positivie\n";
            print "Please re-enter\n\n";
        }
    } until ($temp>=0);

    if ($temp>0)
    {
        $studentID[$count]=$temp;
        print "Enter first name ";
        $firstName[$count]=<STDIN>;
        print "Enter last name ";
        $lastName[$count]=<STDIN>;
        print "Enter amount due ";
        $amountDue[$count]=<STDIN>;
       
        $count++;
    }
} until ($temp == 0);



# OK.....your assignment. You should display a menu. The options are
#   1) Print out the total owed to the university (that is, add all the numbers in @amountDue)
#    2) Scan for a specific ID number. That is, the user should be asked to input a studentID
#        number. The program should look through the @studentID array. If the number IS NOT
#        found, print out a message "Number not found". If the number is found, print out
#        the number, first name, last name, and amount due.
#   3) Terminate the program



# the loop below is for diagnostics. You will eventually remove it. It also demonstrates problems with the input loop

for($count=0;$count<=$#studentID;$count++)
{
    printf "%5d %10s %10s %10.2f\n",$studentID[$count],$firstName[$count],$lastName[$count],
    $amountDue[$count];
}