Ruby program to calculate parallelogram circumference

Views: 19   

Following program shows you how to calculate parallelogram circumference.
This program gets parallelogram base and side from user and calculates circumference and prints it using following formula
Circumference = 2 X base X side

 puts "Please enter base of parallelogram:"
 parallelogramBase = gets.to_f
 puts "Please enter side of parallelogram:"
 parallelogramSide = gets.to_f
 circumferenceOfParallelogram = 2 * (parallelogramBase + parallelogramSide)
 puts "Circumference of parallelogram is: #{circumferenceOfParallelogram}"


Please enter base of parallelogram: 
Please enter side of parallelogram: 
Circumference of parallelogram is: 80.0
On By