Ruby program to find the area of the rectangle

bookmark

=begin 
Ruby program to find Area of Rectangle.
=end

# input length and breadth, and 
# convert them to float value
puts "Enter length:"
l=gets.chomp.to_f
puts "Enter width:"
w=gets.chomp.to_f

# calculating area 
area=l*w

# printing the result
puts "Area of Rectangle is #{area}"

 


Output:

First run:
Enter length:
12.3
Enter width:
5
Area of Rectangle is 61.5

Second run:
Enter length:
1.234
Enter width:
0.78
Area of Rectangle is 0.96252