Ruby program to convert kilograms to grams

Views: 28   

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

puts "Please enter kilograms:"
 kilograms = gets.to_f
 grams = kilograms * 1000
 puts "#{grams} Grams"

Output:

Please enter kilograms:
5
5000.0 Grams
On By