Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #Lab 10
- #Anh-Quan Dang
- #040-793-157
- #Section 323
- #myCalc.sh
- function add(){
- echo "add"
- ((total = $1 + $2))
- echo "$1 + $2 = (($total))"
- }
- function sub(){
- echo "sub"
- ((total = $1 - $2))
- echo "$1 - $2 = (($total))"
- }
- echo "Please enter C) Calculation or X for exit "
- read choice
- #first case
- case $choice in
- c|C)
- echo "Please enter an integer or X to exit"
- read ans
- #second case
- case $ans in
- x|X)
- $exit
- ;;
- *)
- echo "+ for adding"
- echo "- for subtracting"
- echo "X for exit"
- read choices
- #third case
- case $choices in
- +)
- clear
- echo "works on +"
- echo "Please enter an integer or X to exit"
- read an
- case $an in
- x|X)
- $exit
- ;;
- *)
- add $ans $an
- ;;
- esac
- ;;
- -)
- clear
- echo "Please enter an integer or X to exit"
- read an
- echo "works on -"
- case $an in
- x|X)
- $exit
- ;;
- *)
- sub $ans $an
- ;;
- esac
- ;;
- x|X)
- $exit
- ;;
- esac #end of third case
- ;;
- x|X)
- $exit
- ;;
- esac #end of second case
- esac #end of first case
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement