Advertisement
solidsnake

OS Converter Exercise

Jan 29th, 2014
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.07 KB | None | 0 0
  1. #Author - MR
  2. #Date modified - 1/29/14
  3.  
  4. until [ "$choice" == "3" ]
  5. do
  6.     echo "What do you want to convert?"
  7.     echo "============================"
  8.         echo "1. Celsius to Fahrenheit"
  9.         echo "2. Fahrenheit to Celsius"
  10.         echo "3. Exit"
  11.         echo "============================"
  12.         echo
  13.         echo -n "Enter choice: "
  14.         read choice
  15.         echo
  16.  
  17.  
  18.     fah_to_cel()
  19.     {
  20.             echo -n "Enter fahrenheit: "
  21.             read fah
  22.             a=32
  23.             b=0.56
  24.             echo -n "$fah FAHRENHEIT in CELSIUS is: "
  25.             echo -n "$fah $a $b" | awk '{ print ($1-$2) * $3 }'
  26.             echo
  27.     }
  28.  
  29.     cel_to_fah()
  30.     {
  31.         echo -n "Enter celsius: "
  32.             read cel
  33.             c=1.8
  34.             d=32
  35.             echo -n "$cel CELSIUS in FAHRENHEIT is: "
  36.             echo -n "$cel $c $d" | awk '{ print ($1*$2) + $3 }'
  37.             echo
  38.     }
  39.  
  40.  
  41.     if [ "$choice" == "1" ]
  42.     then
  43.             fah_to_cel
  44.     elif [ "$choice" == "2" ]
  45.     then
  46.             cel_to_fah
  47.     elif [ "$choice" == "3" ]
  48.     then
  49.         echo "Goodbye"
  50.     echo
  51.         else
  52.             echo "Invalid choice"
  53.     fi
  54.  
  55. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement