Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. #!/bin/bash
  2. #Lab 10
  3. #Anh-Quan Dang
  4. #040-793-157
  5. #Section 323
  6. #myCalc.sh
  7.  
  8. function add(){
  9. echo "add"
  10. ((total = $1 + $2))
  11. echo "$1 + $2 = (($total))"
  12. }
  13.  
  14. function sub(){
  15. echo "sub"
  16. ((total = $1 - $2))
  17. echo "$1 - $2 = (($total))"
  18. }
  19. echo "Please enter C) Calculation or X for exit "
  20. read choice
  21. #first case
  22. case $choice in
  23. c|C)
  24. echo "Please enter an integer or X to exit"
  25. read ans
  26. #second case
  27. case $ans in
  28. x|X)
  29. $exit
  30. ;;
  31. *)
  32. echo "+ for adding"
  33. echo "- for subtracting"
  34. echo "X for exit"
  35. read choices
  36. #third case
  37. case $choices in
  38. +)
  39. clear
  40. echo "works on +"
  41. echo "Please enter an integer or X to exit"
  42. read an
  43. case $an in
  44. x|X)
  45. $exit
  46. ;;
  47.  
  48. *)
  49. add $ans $an
  50. ;;
  51. esac
  52.  
  53. ;;
  54.  
  55. -)
  56. clear
  57. echo "Please enter an integer or X to exit"
  58. read an
  59. echo "works on -"
  60. case $an in
  61. x|X)
  62. $exit
  63. ;;
  64. *)
  65. sub $ans $an
  66. ;;
  67.  
  68. esac
  69.  
  70. ;;
  71.  
  72. x|X)
  73. $exit
  74. ;;
  75.  
  76. esac #end of third case
  77.  
  78. ;;
  79. x|X)
  80. $exit
  81. ;;
  82. esac #end of second case
  83. esac #end of first case
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement