Ruby program to calculate triangle circumference
Following program shows you how to calculate triangle circumference.
This program gets triangle sides from user and calculates circumference and prints it using following formula
Circumference = side1 + side2 + side3
puts "Enter the side1 of triangle:"
triangleSide1 = gets.to_f
puts "Enter the side2 of triangle:"
triangleSide2 = gets.to_f
puts "Enter the side3 of triangle:"
triangleSide3 = gets.to_f
circumferenceOfTriangle = triangleSide1 + triangleSide2 + triangleSide3
puts "Circumference of triangle is: #{circumferenceOfTriangle}"
Output:
Enter the side1 of triangle:
20
Enter the side2 of triangle:
10
Enter the side3 of triangle:
30
Circumference of triangle is: 60.0