A very simple program that I wrote to solve the area of the circle. What does the program will do is to ask the user to give the value in radius of the circle and it will solve it's area the code in Ruby is very simple and easy to understand.
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
area.rb
# area.rb
# Written By: Mr. Jake R. Pomperada, MAED-IT
# December 15, 2017
# Tool : Ruby and Sublime Text Editor
# Location : Bacolod City, Negros Occidental Philippines
# method to compute the area of a circle
def solve_area(radius)
area_circle = (3.1415 * radius.to_f * radius.to_f )
print "\n\n"
print "The area of circle is #{area_circle.round(2)}."
print "\n\n"
end
radius_input =""
answer = ""
until answer.downcase == "n" do
print "\n\n"
print "===== AREA OF THE CIRCLE SOLVER IN RUBY ====="
print "\n\n"
print "Created by Mr. Jake R. Pomperada"
print "\n\n"
print "Give the radius of the Circle : "
radius_input = gets.to_i
solve_area(radius_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"
No comments:
Post a Comment