Cara membuat shell program bash menu makanan



Kali ini saya akan membagikan sebuah program bash menu makanan yang menggunakan perulangan.
Berikut adalah kode programs untuk membuat menu makanan :

#!/bin/bash
lagi = 'y'
while $lagi;
do
clear
echo "+++++++++++++++++++++++++++++++++++++++++++++++";
echo " PILIH PAKET MAKANAN ";
echo "+++++++++++++++++++++++++++++++++++++++++++++++";
echo "1. PAKET 1: Paha Bawah+Nasi+Es Teh (Rp.8.000)";
echo "2. PAKET 2: Lele+Nasi+Es Teh (Rp.10.000)";
echo "3. PAKET 3: Paha Atas+Nasi+Es Teh (Rp.10.000)";
echo "4. PAKET 4: Kakap+Nasi+Es Teh (Rp.12.000)";
echo "5. PAKET 5: Paha Utuh+Nasi+Es Teh (Rp.15.000)";
echo "0. K E L U A R ";
echo "+++++++++++++++++++++++++++++++++++++++++++++++";
read -p "Masukan Pilihan [1-5] :" pil;
echo "+++++++++++++++++++++++++++++++++++++++++++++++";
if [ $pil -eq 1 ];
then
echo 'PAKET 1'
echo -n "Masukan jumlah : ";
read jum
let bayar=jum*8000;
elif [ $pil -eq 2 ];
then
echo 'PAKET 2'
echo -n "Masukan jumlah : ";
read jum
let bayar=jum*10000;
elif [ $pil -eq 3 ];
then
echo 'PAKET 3'
echo -n "Masukan jumlah : ";
read jum
let bayar=jum*10000;
elif [ $pil -eq 4 ];
then
echo 'PAKET 4'
echo -n "Masukan jumlah : ";
read jum
let bayar=jum*12000;
elif [ $pil -eq 5 ];
then
echo 'PAKET 5'
echo -n "Masukan jumlah : ";
read jum
let bayar=jum*15000;
elif [ $pil -eq 0 ];
then
exit 0
else
echo "Maaf, tidak tersedia"
echo $lagi;
fi
echo "Harga Total = Rp. $bayar"
echo "+++++++++++++++++++++++++++++++++++++++++++++++"
echo "Press [Enter] key to continue...";
read lagi;
done

HASIL PROGRAM :


Sekian tutorial program shell bash linux.Terima Kasih.

Previous
Next Post »