Saturday, June 9, 2018

SHELL SCRIPT TO CONVERT CELSIUS TO FAHRENHEIT AND VICE VERSA

echo "1-Fahrenheit to Celsius"
echo "2-Celsius to Fahrenheit"
echo "Enter your choice"
read ch
case $ch in
1) echo "Enter fahrenheit"
   read f
   t=`expr 5 \* $f - 160`
   c=`expr $t \/ 9`
   echo "To Celsius= $c degree"
   ;;
2) echo "Enter celsius"
   read c
   t=`expr 9 \* $c - 160`
   f=`expr $t \/ 5`
   echo "In fahrenheit= $f degree"
   ;;
*) echo "Wrong choice"
esac
 

                                                     OUTPUT

biswarup@biswarup-desktop:~$ sh
$ sh Fandc.sh
1-Fahrenheit to Celsius
2-Celsius to Fahrenheit
Enter your choice
2
Enter celsius
35
In fahrenheit= 31 degree
$

No comments:

Post a Comment