Q:

Write a Ruby program which accept the radius of a circle from the user and compute the parameter and area

0

 Write a Ruby program which accept the radius of a circle from the user and compute the parameter and area.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Ruby Code:

radius = 5.0
perimeter = 0.0
area = 0.0
print "Input the radius of the circle: "
radius = gets.to_f
perimeter = 2 * 3.141592653 * radius
area = 3.141592653 * radius * radius
puts "The perimeter is #{perimeter}."
puts "The area is #{area}."
Output:
Input the radius of the circle: The perimeter is 31.41592653.
The area is 78.539816325.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now