I can't seem to debug the error in the computation of
case $code in
${menuCode[0]} )
CBcost=$(echo "${menuItemsCost[0]} * $quantity" |bc)
sumOfCheeseBurgers=$(echo "$sumOfCheeseBurgers + $CBcost" |bc)
;;
I need to be able to add all the sum of Burgers and store it to sumOfBurgers everytime the user enters Y for another transaction. However, I keep getting a (standard_in) 1: syntax error. How do I properly express sumOfBurgers=sumOfBurgers + CBcost?
declare -a menuItems=( 'Cheese Burger' 'Ham Burger' 'Spaghetti' 'Fried Chicken' 'Softdrinks' )
declare -a menuItemsCost=( 25.00 20.00 24.00 30.00 15.00 )
declare -a menuCode=( CB HB SP FC SD )
clear
printf "MENU\n"
printf "=================================\n"
printf "CODE\tDESCRIPTION\t PRICE\t|\n"
echo "================================="
printf "${menuCode[0]} |\t${menuItems[0]}\t| ${menuItemsCost[0]} |\n"
printf "${menuCode[1]} |\t${menuItems[1]}\t| ${menuItemsCost[1]} |\n"
printf "${menuCode[2]} |\t${menuItems[2]}\t| ${menuItemsCost[2]} |\n"
printf "${menuCode[3]} |\t${menuItems[3]}\t| ${menuItemsCost[3]} |\n"
printf "${menuCode[4]} |\t${menuItems[4]}\t| ${menuItemsCost[4]} |\n"
printf "=================================\n"
choice="Y"
while [ $choice == "Y" ]
do
printf "What's your order please? \n[Enter Code]: "
read code
while [ "$code" != "CB" ] && [ "$code" != "HB" ] && [ "$code" != "SP" ] &&
[ "$code" != "FC" ] && [ "$code" != "SD" ]
do
printf "Please enter a valid ORDER code. \n[Enter Code]: "
read code
code=$code
done
printf "Enter Quantity: "
read quantity
printf "Do another transaction [Y/N]?: "
read choice
case $code in
${menuCode[0]} )
CBcost=$(echo "${menuItemsCost[0]} * $quantity" |bc)
sumOfCheeseBurgers=$(echo "$sumOfCheeseBurgers + $CBcost" |bc)
;;
esac
done
printf "$sumOfCheeseBurgers\n"
help printf.