Showing posts with label celsius to fahrenheit. Show all posts
Showing posts with label celsius to fahrenheit. Show all posts

Wednesday, December 13, 2017

Celsius To Fahrenheit Converter in Ruby

Here is a sample program that will ask the user to give a value in temperature in Celsius and it will converted into Fahrenheit equivalent in Ruby. I created a method in this example to compute the Fahrenheit equivalent.

 I am currently accepting programming and web development work kindly contact me in the following email address for further details. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental is (034) 4335675.





Sample Program Output


Program Listing

temp.rb


# temp.rb
# Written By: Mr. Jake R. Pomperada, MAED-IT
# December 13, 2017
# Tool : Ruby and Sublime Text Editor
# Location : Bacolod City, Negros Occidental Philippines

# method to celsius to fahrenheit

def convert_temp(celsius)
  fahrenheit = (celsius.to_f * 9 / 5) + 32
  print "\n\n"
  print "The equivalent is: #{fahrenheit.round(2)} degrees fahrenheit."
  print "\n\n"
end

celsius_input =""
answer = ""

until answer.downcase == "n" do 
print "\n\n"
print "===== CELSIUS TO FAHRENHEIT CONVERTER IN RUBY ====="
print "\n\n"
print "Created by Mr. Jake R. Pomperada"
print "\n\n"
print "Give temperature in celsius : "
celsius_input = gets.to_i

convert_temp(celsius_input)

print "\n"
print "Do you want to continue Y/N ? : "
answer= gets.chop
end  
print "\n\n"
    print "End of Program"
    print "\n\n"




Tuesday, September 16, 2014

Celsius To Fahrenheit Solver in Bash

This is another conversion of temperature that I wrote using Bash script. In my previous article I wrote a program that will ask the user to enter the temperature in Fahrenheit and then it will convert to its Celsius temperature equivalent. By this time it another way around from Celsius it will convert to its Fahrenheit value.

Take note in my sample bash program I always adding some functionalities like asking the user if the user wants again to run the program so that it can give a different value and then give us the different converted values. It makes our bash script more versatile in many ways. I hope you will find my sample bash script programs more useful in your learning how to program in bash in UNIX, MAC OS and 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

#!/bin/bash

# Celsius To Fahrenheit 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 (====== CELSIUS TO FAHRENHEIT SOLVER  =====)";
echo -e "\n"

read -p  "Please Enter Temperature in Celsius : " celsius_values
compute=$(echo "scale=2;((($celsius_values * 9/5 +32)))"|bc)

echo -e "\nTemperature in Celsius is $celsius_values\xe2\x84\x83 ."
echo -e "The equivalent temperature in Fahrenheit 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