daily pastebin goal
40%
SHARE
TWEET

Untitled

a guest Jan 22nd, 2018 49 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. penjumlahan(){
  3.     clear
  4.     echo "=== Penjumlahan ==="
  5.     read -p "Angka 1 : " a;
  6.     read -p "Angka 2 : " b;
  7.     hasil=$[a+b];
  8.     echo "Hasil : " $hasil;
  9. }
  10. pengurangan(){
  11.     clear
  12.     echo "=== Pengurangan ==="
  13.     read -p "Angka 1 : " a;
  14.     read -p "Angka 2 : " b;
  15.     hasil=$[a-b];
  16.     echo "Hasil : " $hasil;
  17. }
  18. perkalian(){
  19.     clear
  20.     echo "=== Perkalian ==="
  21.     read -p "Angka 1 : " a;
  22.     read -p "Angka 2 : " b;
  23.     hasil=$[a*b];
  24.     echo "Hasil : " $hasil;
  25. }
  26. modulus(){
  27.     clear
  28.     echo "=== Modulus ==="
  29.     read -p "Angka 1 : " a;
  30.     read -p "Angka 2 : " b;
  31.     hasil=$[a%b];
  32.     echo "Hasil : " $hasil;
  33. }
  34. pembagian(){
  35.     clear
  36.     echo "=== Pembagian ==="
  37.     read -p "Angka 1 : " a;
  38.     read -p "Angka 2 : " b;
  39.     hasil=$[a/b];
  40.     echo "Hasil : " $hasil;
  41. }
  42. menu(){
  43.     clear
  44.     echo "PERHITUNGAN SEDERHANA"
  45.     echo "1. Penjumlahan"
  46.     echo "2. Pengurangan"
  47.     echo "3. Perkalian"
  48.     echo "4. Pembagian"
  49.     echo "5. Modulus"
  50.     echo "6. Exit"
  51.     read -p "Pilihan anda [1-6] :" pil;
  52.     while [ -z $pil ] || [ $pil -lt 1 ] || [ $pil -gt 6 ];
  53.     do
  54.     read -p "Pilihan anda [1-6] :" pil;
  55.     done
  56. }
  57. #block utama
  58. lagi='y'
  59. while [ $lagi == 'y' ] || [ $lagi == 'Y' ]
  60. do
  61. menu;
  62. case $pil in
  63. 1) penjumlahan
  64. ;;
  65. 2) pengurangan
  66. ;;
  67. 3) perkalian
  68. ;;
  69. 4) pembagian
  70. ;;
  71. 5) modulus
  72. ;;
  73. 6) clear;
  74. exit 0;
  75. ;;
  76. *)
  77. echo "$pil, tidak ada dalam pilihan"
  78. ;;
  79. esac
  80. echo -n "Ke Menu (y/t): ";
  81. read lagi;
  82. done
RAW Paste Data
Top