| | |
Help With Case Nesting(Restaurant Ordering Simulator)
Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Sep 2009
Posts: 9
Reputation:
Solved Threads: 0
I have a problem with the Nesting of case statements.
This is a Simple restaurant program which simulates food ordering.
I used Case statements to Display Multiple nested menus base on the users choice
But i seem to have a problem with the esac,seems my nesting is wrong.Pleas any help or advice will be appreciated.
This is a Simple restaurant program which simulates food ordering.
I used Case statements to Display Multiple nested menus base on the users choice
But i seem to have a problem with the esac,seems my nesting is wrong.Pleas any help or advice will be appreciated.
Shell Scripting Syntax (Toggle Plain Text)
#!/bin/bash clear # display menu echo "-------------------------------" echo " Superman Restaurant" echo "-------------------------------" echo " Main Menu" echo "-------------------------------" echo " $(date)" echo "-------------------------------" echo "1. Display Meal Menu." echo "2. Display Drinks." echo "3. Display Desert." echo "4. Exit" # get input from the user read -p "Enter your choice [ 1 -4 ] " choice # make decision using case..in..esac case $choice in 1) clear echo "-------------------------------" echo " Superman Restaurant" echo "-------------------------------" echo " Meal Menu" echo "-------------------------------" echo echo "1. Chichen Fried Rice 10RM." echo "2. Tom Yam Fried Rice 15RM." echo "3. Lovers Rice 10RM." echo "4. Curry Rice 12RM." echo "5. Jelof Rice 15RM." echo "6. Fairy Rice 10RM." echo "7. Spicy Stew Rice 18RM." echo "8. Exit" read -p "Enter your choice [ 1 -7 ] " Meal case $Meal in 1) echo " You Just Selected Chichen Fried Rice" read -p "Press [Enter] to continue order..." if $readEnterKey true then echo echo "Your Order has been Completed" else echo "" fi ;; 2) echo " You Just Selected Tom Yam Fried Rice" read -p "Press [Enter] to continue order..." if $readEnterKey true then echo echo "Your Order has been Completed" else echo "" fi ;; 3) echo " You Just Selected Lovers Rice" read -p "Press [Enter] to continue order..." if $readEnterKey true then echo echo "Your Order has been Completed" else echo "" fi ;; 4) echo " You Just Selected Curry Rice" read -p "Press [Enter] to continue order..." if $readEnterKey true then echo echo "Your Order has been Completed" else echo "" fi ;; 5) echo " You Just Selected Jelof Rice" read -p "Press [Enter] to continue order..." if $readEnterKey true then echo echo "Your Order has been Completed" else echo "" fi ;; 6) echo " You Just Selected Fairy Rice" read -p "Press [Enter] to continue order..." if $readEnterKey true then echo echo "Your Order has been Completed" else echo "" fi ;; 7) echo " You Just Selected Spicy Rice" read -p "Press [Enter] to continue order..." if $readEnterKey true then echo echo "Your Order has been Completed" else echo "" fi ;; 8) echo "Bye!" exit 0 ;; *) echo "Error: Invalid option..." read -p "Press [Enter] key to continue..." ;; esac 2) clear echo "-------------------------------" echo " Superman Restaurant" echo "-------------------------------" echo " Drinks Menu" echo "-------------------------------" echo echo "1. Kikapo Juice 2RM." echo "2. Orange Juice 3RM." echo "3. Apple Juice 3RM." echo "4. Lemon Ice Tea 1RM." echo "5. Mango Lassi 5RM." echo "6. Herba Tea 2RM." echo "7. Cococola 2RM" echo "8. Bye!" read -p "Enter your choice [ 1 -8 ] " Drinks case $Drinks in 1) echo " You Just Selected Kikapo Juice" read -p "Press [Enter] to continue order..." if $readEnterKey true then echo echo "Your Order has been Completed" else echo "" fi 2) echo " You Just Selected Orange Juice" read -p "Press [Enter] to continue order..." if $readEnterKey true then echo echo "Your Order has been Completed" else echo "" fi 3) echo " You Just Selected Apple Juice" read -p "Press [Enter] to continue order..." if $readEnterKey true then echo echo "Your Order has been Completed" else echo "" fi 4) echo " You Just Selected Lemon Juice" read -p "Press [Enter] to continue order..." if $readEnterKey true then echo echo "Your Order has been Completed" else echo "" fi 5) echo " You Just Selected Mango Juice" read -p "Press [Enter] to continue order..." if $readEnterKey true then echo echo "Your Order has been Completed" else echo "" fi 6) echo " You Just Selected Herbal Tea" read -p "Press [Enter] to continue order..." if $readEnterKey true then echo echo "Your Order has been Completed" else echo "" fi 7) echo " You Just Selected Cocacola" read -p "Press [Enter] to continue order..." if $readEnterKey true then echo echo "Your Order has been Completed" else echo "" fi 8) echo "Bye!" exit 0 ;; *) echo "Error: Invalid option..." read -p "Press [Enter] key to continue..." ;; esac 3) clear echo "-------------------------------" echo " Superman Restaurant" echo "-------------------------------" echo " Desert Menu" echo "-------------------------------" echo echo "1. Ferry Cake 15RM." echo "2. Chocolate ice Cream 10RM." echo "3. Vanilla Cake 13RM." echo "4. Queen Cake 12RM." echo "5. Bye!" read -p "Enter your choice [ 1 -5 ] " Desert case $Desert in 1) echo " You Just Selected Ferry Cake" read -p "Press [Enter] to continue order..." if $readEnterKey true then echo echo "Your Order has been Completed" else echo "" fi 2) echo " You Just Selected Chocolate ice Cream" read -p "Press [Enter] to continue order..." if $readEnterKey true then echo echo "Your Order has been Completed" else echo "" fi 3) echo " You Just Selected Vanilla Cake" read -p "Press [Enter] to continue order..." if $readEnterKey true then echo echo "Your Order has been Completed" else echo "" fi 4) echo " You Just Selected Queen Cake" read -p "Press [Enter] to continue order..." if $readEnterKey true then echo echo "Your Order has been Completed" else echo "" fi 5) echo "Bye!" exit 0 ;; *) echo "Error: Invalid option..." read -p "Press [Enter] key to continue..." ;; esac 4) echo "Bye!" exit 0 ;; *) echo "Error: Invalid option..." read -p "Press [Enter] key to continue..." ;; esac
•
•
Join Date: Dec 2008
Posts: 64
Reputation:
Solved Threads: 13
0
#2 Oct 7th, 2009
You are missing ;; before 2) on line 168 or thereabouts and in many other places.
Last edited by cfajohnson; Oct 7th, 2009 at 7:49 am.
Chris F.A. Johnson
http://cfajohnson.com
http://cfajohnson.com
![]() |
Similar Threads
- A shell script that will simulate food ordering system in a restaurant (Shell Scripting)
- Restaurant Menu Program (C++)
- ATM Simulator Help PLEASE :) (C)
- Case from hell -- fries motherboards (Troubleshooting Dead Machines)
- c++ cashier (C++)
- Ordering an array (Java)
- Iinformation systems case study entities and events?? (Computer Science)
- Simulator Engineer - Portland, OR (Software Development Job Offers)
- Question on CPU Simulator (Assembly)
- Grpahics card overheating (Monitors, Displays and Video Cards)
Other Threads in the Shell Scripting Forum
- Previous Thread: Log file analysis based on time range
- Next Thread: Can somebody help with looping my command?
| Thread Tools | Search this Thread |
Tag cloud for Shell Scripting





