Final_Project

Partners:
Allen Tan
Manuel Montiel

The Code:
#!/bin/bash
echo “List of Produce”
echo “1. Apple”
echo “2. Banana”
echo “3. Pear”
echo “4. Strawberry”
echo “5. Grape”
echo “6. Watermellon”
echo “999. Quit”
PNumber=0

while [ $PNumber -ne 999 ]; do
        echo “Please Enter Produce Number or 999 to quit”
        read PNumber

        if [ $PNumber = 999 ]; then
                echo “Finished”
        elif [ $PNumber = 1 ]; then
                echo “Apple Price is \$1.00”
        elif [ $PNumber = 2 ]; then
                echo “Banana Price is \$2.00”
        elif [ $PNumber = 3 ]; then
                echo “Pear Price is \$3.00”
        elif [ $PNumber = 4 ]; then
                echo “Strawberry Price is \$4.00”
        elif [ $PNumber = 5 ]; then
                echo “Grape Price is \$5.00”
        elif [ $PNumber = 6 ]; then
                echo “Watermellon Price is \$6.00”
        else
                $PNumber=999
                echo “Finished”
        fi
done

Explanation:
This particular code code gives a list of produce to a user, and asks the user to select an item. When the item is selected, the compiler then goes through the if…else statements to pick the price for the specific item selected. At the end of the code the choice is then posed to the user of whether the program should be ran again or be terminated. If the user does choose to run the program again, the produce should be selected from the list. On the other hand, any other number pressed will result in termination with “Finished” being displayed on the screen. As of now this code only has 6 items, however, it can potentially hold as many items as  needed in order to serve a larger purpose. The values of the produce are arbitrary as of now, but they could be modified if needed. This code (or the expanded version of it) can be used in supermarkets and other convenience stores in order to bring up the prices of products with ease of access.

Leave a Reply

Your email address will not be published. Required fields are marked *