Jumat, November 12, 2010

Shell Linux For Ujian PTKI

Program Kalkulator GEJE

a=20
b=5
clear
let tambah=a+b
let kurang=a-b
let kali=a*b
echo "$a+$b=$tambah"
echo "$a-$b=$kurang"
echo "$a*$b=$kali"
echo

Program Menu

clear
echo "menu"
echo "1. Bakso"
echo "2. Gado-Gado"
echo "3. Exit"
echo -n "Masukan Pilihan                :"
read pil
if(($pil==1));
then
sh habibah;
read;
elif(($pil==2));
then
echo - "Banyalnya Porsi";
read jum;
let bayar=jum*6000;
elif(($pil==3));
then
exit 0
else
echo "Sorry, tidak tersedia";
exit 1
fi

echo "Harga Bayar               :Rp. "$bayar;
echo "Terima Kasih";
echo


Program Kalkulator Beneran dikit

clear
echo "kalkulator";
echo "menu";
echo "1. Penjumlahan";
echo "2. Pengurangan";
echo "3. Perkalian";
echo "4. Pembagian";
echo -n "Pilihan Anda:";
read pil;
if(($pil==1));
then
echo -n "Bilangan Pertama:";
read bil1;
echo -n "Bilangan Kedua:";
read bil2;
let hasil=bil1+bil2;
elif(($pil==2));
then
echo -n "Bilangan Pertama:";
read bil1;
echo -n "Bilangan Kedua:";
read bil2;
let hasil=bil1-bil2;
elif(($pil==3));
then
echo -n "Bilangan Pertama:";
read bil1;
echo -n "Bilangan Kedua:";
read bil2;
let hasil=bil1*bil2;
elif(($pil==4));
then
echo -n "Bilangan Pertama:";
read bil1;
echo -n "Bilangan Kedua:";
read bil2;
let hasil=bil1/bil2;
elif(($pil==5));
then
echo "maav pilihan anda salah";
exit 0
else
exit 1
fi
echo "hasilnya adalah=$hasil";
echo "thanks";

Tidak ada komentar:

Posting Komentar