In this article I would like to share with you a sample program that I wrote using BASH scripting language or Bourne Again Shell in Linux operating system I called this program Fahrenheit To Celsius Solver in Bash. What the program will do when the user run the script using ./fah.sh or bash fah.sh it will ask the user to enter the temperature in Fahrenheit and the program will convert it to its Celsius equivalent.
The script is very short and very easy to understand a good way to automate some math problems using Bash as our programming language under the Linux environment. If you have some questions please send me an email at jakerpomperada@yahoo.com and jakerpomperada@gmail.com.
Thank you very much.
Sample Output of Our Program
Program Listing
# Fahrenheit To Celsius Solver
# Written By Mr. Jake R. Pomperada, MAED-IT
# Operating System : UBUNTU 14.04
# Date : September 16, 2014
start()
{
clear
echo -e "\n"
echo -e "\t (====== FAHRENHEIT TO CELSIUS SOLVER =====)";
echo -e "\n"
read -p "Please Enter Temperature in Fahrentheit : " fah
compute=$(echo "scale=2;((($fah -32) * 5) / 9)"|bc)
echo -e "\nTemperature in Fahreneit is $fah\xe2\x84\x83 ."
echo -e "The equivalent temperature in Celsius is $compute\xe2\x84\x83."
while true; do
echo -e "\n"
read -p "More (Y/N)? " answer
case $answer in
[Yy]* ) start; break;;
[Nn]* ) bye; break;;
* ) echo "Please answer yes or no. ";;
esac
done
}
bye()
{
echo -e "\n"
echo -e "\t Thank You For Using This Program.";
echo -e "\n\n";
}
start
DOWNLOAD FILE HERE
No comments:
Post a Comment