Register
It is currently Mon Sep 01, 2014 7:54 pm

Temp Conversion Script


All times are UTC - 6 hours


Post new topic Reply to topic  [ 1 post ] 
Author Message
 PostPosted: Wed Jul 20, 2005 8:05 am   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 666
Location: Des Moines, Iowa
Saw a perl script that did this, wanted to do a bash script that did the same thing :)

Code:
#!/bin/bash
mainmenu ()
{
clear; echo "Temp Conversion Script";echo ""; menu="\t1) \tFahrenheit to Celsius Conversion\n\t2)\tCelsius to Fahrenheit Conversion\n\t0)\tExit";
echo -e "$menu";echo "";read -p "Please choose one of the options above : " option
while true; do
   case $option in
      1)   F2C;
         ;;
      2)   C2F;
         ;;
      0)   option="";
         exit;
         ;;
      *)   echo "That choice was invalid!!";
         ;;
   esac
done
}
F2C ()
{
echo "Fahrenheit to Celsius Conversion";echo "Enter the temperature (in Fahrenheit):";read FT
tconv=`echo "($FT - 32) * 5 / 9 " |bc`
echo -en "The Temperature in Celsius is ";echo "$tconv" ;read -p "Hit RETURN to continue" temp;mainmenu
}
C2F ()
{
echo "Celsius to Fahrenheit Conversion";echo "Enter the temperature (in Celsius):";read CT
tconv=`echo "$CT * 9 / 5 + 32 " |bc`
echo -en "The Temperature in Fahrenheit is ";echo "$tconv";read -p "Hit RETURN to continue" temp;mainmenu
}
mainmenu
exit


Top
 Profile WWW  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP