Command & Development/Shell Script

[Shell Script] Calculator

Richard.Ryu 2022. 9. 20. 17:23
반응형
echo "Calulator"
      echo "***********************"
      echo "1. plus"
      echo "2. minus"
      echo "3. multiplication"
      echo "4. division"
      echo "***********************"
     
      read Calulator
      if [ $Calulator == 1 ]
          then
          echo "You typed Number -> 1. plus"
          echo "Typed number1"
          read number1
          echo "Typed number2"
          read number2
              echo "-------result---------"
              sum=$(($number1+$number2))
              echo $sum
      elif [ $Calulator == 2 ]
          then
          echo "You typed Number -> 2. minus"
          echo "Typed number1"
          read number1
          echo "Typed number2"
          read number2
              echo "-------result---------"
              mns=$(($number1-$number2))
              echo $mns
     
      elif [ $Calulator == 3 ]
          then
          echo "You typed Number -> 3. multiplication"
          echo "Typed number1"
          read number1
          echo "Typed number2"
          read number2
              echo "-------result---------"
              multi=$(($number1*$number2))
              echo $multi
     
      elif [ $Calulator == 4 ]
          then
          echo "You typed Number -> 4. division"
          echo "Typed number1"
          read number1
          echo "Typed number2"
          read number2
              echo "-------result---------"
              div=$(($number1/$number2))
              echo $div
     
      fi​

 

반응형