Virajsinh

Swich_Case_OS_Script

Sep 14th, 2017
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. i=1
  2. echo "--------------------"
  3. echo "Enter the Values A And B"
  4. echo "--------------------"
  5.  
  6. while [ $i=1 ]
  7. do
  8. echo "Enter Value A :"
  9. read a
  10. echo "--------------------"
  11. echo "Enter Value B :"
  12. read b
  13. echo "--------------------"
  14.  
  15. echo "--------------------"
  16. echo "1. Addition"
  17. echo "2. Subtarction"
  18. echo "3. Multiplcation"
  19. echo "4. Divsion"
  20. echo "--------------------"
  21.  
  22. echo "Enter Your Option :"
  23. read ch
  24.  
  25. case $ch in
  26.  
  27. 1) echo "Addition"
  28. c=$(echo "scale=2;$a + $b"|bc)
  29. echo "--------------------"
  30. echo "Addition is : "$c
  31. echo "--------------------"
  32. ;;
  33.  
  34. 2) echo "Subtraction"
  35. c=$(echo "scale=2;$a - $b"|bc)
  36. echo "--------------------"
  37. echo "Subtraction is : "$c
  38. echo "--------------------"
  39. ;;
  40.  
  41. 3)echo "Multiplcation"
  42. c=$(echo "scale=2;$a * $b"|bc)
  43. echo "--------------------"
  44. echo "Multiplcatio is : "$c
  45. echo "--------------------"
  46. ;;
  47.  
  48. 4)echo "Divsion"
  49. c=$(echo "scale=2;$a / $b"|bc)
  50. echo "--------------------"
  51. echo "Divsion is : "$c
  52. echo "--------------------"
  53. ;;
  54.  
  55. *) echo "Please enter some option"
  56. ;;
  57.  
  58. esac
  59.  
  60. echo "Enter 2 to Exit :"
  61. read i
  62. if [ $i -ne 1 ]
  63. then
  64. exit
  65. fi
  66. done
Add Comment
Please, Sign In to add comment