You are Here: Home > Computer Subjects > Unix Shell Programming…
Centigrade to Fahrenheit and Fahrenheit to Centigrade Conversion
Code:
clear i=0 while test $i -eq 0 do echo " Menu" echo "....................................." echo echo "1. Centigrade to Fahrenheit." echo "2. Fahrenheit to Centigrade." echo "3. Exit." echo echo echo -n "Enter your choice==> " read ch case $ch in 1) i=1 echo -n "Enter the Centigrade value==> " read c a=`expr $c \* 9` b=`expr $a + 160` f=`expr $b / 5` echo $c"C = " $f"F" ;; 2) i=1 echo -n "Enter the Fahrenheit value==> " read f a=`expr $f - 32` b=`expr $a \* 5` c=`expr $b / 9` echo $f"F = " $c"C" ;; 3) i=1 exit ;; *) echo "Please select a valid option." echo echo ;; esac done
Output:
Menu ..................................... 1. Centigrade to Fahrenheit. 2. Fahrenheit to Centigrade. 3. Exit.
Enter your Choice==> 1
Enter the Centigrade value==> 100
100C = 212F
Click Here to Find Latest Jobs and Current Affairs