#!/bin/bash
lagi=’y';
while [ $lagi == 'y' ] || [ $lagi == 'Y' ];
do
clear;
echo ” -= Kalkulator Sederhana =- “;
echo ” -= Menu =- ” ;
echo ” 1. Penjumlahan (+) “;
echo ” 2. Pengurangan (-) “;
echo ” 3. Perkalian (*) “;
echo ” 4. Pembagian (/) “;
echo ” 5. Modulo (%) “;
echo ” 6. Exit “;
read -p ” Operasi yang akan dilakukan [1-5] : ” pil;
if [ $pil -eq 1 ]; then
echo “=Penjumlahan= “;
echo -n “Bilangan pertama : “;
read bil1;
echo -n “Bilangan Kedua : “;
read bil2;
let bil3=$bil1+$bil2;
echo “Hasil penjumlahan : $bil1 + $bil2 = $bil3″;
elif [ $pil -eq 2 ]; then
echo “=Pengurangan= “;
echo -n “Bilangan pertama : “;
read bil1;
echo -n “Bilangan Kedua : “;
read bil2;
let bil3=$bil1-$bil2;
echo “Hasil pengurangan :$bil1 – $bil2 = $bil3″ ;
elif [ $pil -eq 3 ]; then
echo “=Perkalian= “;
echo -n “Bilangan pertama : “;
read bil1;
echo -n “Bilangan Kedua : “;
read bil2;
let bil3=$bil1*$bil2;
echo “Hasil perkalian :$bil1 * $bil2 = $bil3″;
elif [ $pil -eq 4 ]; then
echo “=Pembagian= “;
echo -n “Bilangan pertama : “;
read bil1
echo -n “Bilangan Kedua : “;
read bil2
let bil3=$bil1/$bil2;
echo “Hasil pembagian :$bil1 / $bil2 = $bil3″;
elif [ $pil -eq 5 ]; then
echo “=Modulo=”;
echo -n “Bilangan pertama : “;
read bil1;
echo -n “Bilangan kedua : “;
read bil2;
let bil3=$bil1%$bil2;
echo “Hasil pembagian :$bil1 % $bil2 = $bil3″;
elif [ $pil -eq 6 ]; then
echo “Exit…..”;
exit 0;
else
echo “anda salah memasukan pilihan”
fi
echo -n “Hitung lagi (y/t) :”;
read lagi;
done
lagi=’y';
while [ $lagi == 'y' ] || [ $lagi == 'Y' ];
do
clear;
echo ” -= Kalkulator Sederhana =- “;
echo ” -= Menu =- ” ;
echo ” 1. Penjumlahan (+) “;
echo ” 2. Pengurangan (-) “;
echo ” 3. Perkalian (*) “;
echo ” 4. Pembagian (/) “;
echo ” 5. Modulo (%) “;
echo ” 6. Exit “;
read -p ” Operasi yang akan dilakukan [1-5] : ” pil;
if [ $pil -eq 1 ]; then
echo “=Penjumlahan= “;
echo -n “Bilangan pertama : “;
read bil1;
echo -n “Bilangan Kedua : “;
read bil2;
let bil3=$bil1+$bil2;
echo “Hasil penjumlahan : $bil1 + $bil2 = $bil3″;
elif [ $pil -eq 2 ]; then
echo “=Pengurangan= “;
echo -n “Bilangan pertama : “;
read bil1;
echo -n “Bilangan Kedua : “;
read bil2;
let bil3=$bil1-$bil2;
echo “Hasil pengurangan :$bil1 – $bil2 = $bil3″ ;
elif [ $pil -eq 3 ]; then
echo “=Perkalian= “;
echo -n “Bilangan pertama : “;
read bil1;
echo -n “Bilangan Kedua : “;
read bil2;
let bil3=$bil1*$bil2;
echo “Hasil perkalian :$bil1 * $bil2 = $bil3″;
elif [ $pil -eq 4 ]; then
echo “=Pembagian= “;
echo -n “Bilangan pertama : “;
read bil1
echo -n “Bilangan Kedua : “;
read bil2
let bil3=$bil1/$bil2;
echo “Hasil pembagian :$bil1 / $bil2 = $bil3″;
elif [ $pil -eq 5 ]; then
echo “=Modulo=”;
echo -n “Bilangan pertama : “;
read bil1;
echo -n “Bilangan kedua : “;
read bil2;
let bil3=$bil1%$bil2;
echo “Hasil pembagian :$bil1 % $bil2 = $bil3″;
elif [ $pil -eq 6 ]; then
echo “Exit…..”;
exit 0;
else
echo “anda salah memasukan pilihan”
fi
echo -n “Hitung lagi (y/t) :”;
read lagi;
done
ConversionConversion EmoticonEmoticon