Ruby program to convert grams to kilograms

Views: 32   

Following program shows you how to convert grams to kilograms.
In this program we get grams from user, once we get those we need to divide with 1000 so that we get in kilograms

 puts "Please enter grams:"
 grams = gets.to_f
 kilograms = grams / 1000
 puts "#{kilograms} Kilograms"

Output:

Please enter grams:
30
0.03 Kilograms
On By