Advertisement
Guest User

converter, kyletcarey

a guest
Oct 11th, 2012
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.46 KB | None | 0 0
  1. # Euro <=> USD, kyletcarey
  2.  
  3. def to_euro(value)
  4.     new_value = value * 0.77310
  5.     puts "#{value} Euros is equal to $#{new_value}."
  6. end
  7.  
  8. def to_usd(value)
  9.     new_value = value * 1.2934
  10.     puts "$#{value} is equal to #{new_value} Euros."
  11. end
  12.  
  13.  
  14. print "What are we converting from? (USD/EURO): "
  15. type = gets.downcase
  16.  
  17. print "And how much are we converting today?: "
  18. value = gets.to_i
  19.  
  20. if type == "usd"
  21.     to_euro(value)
  22. end
  23.  
  24. if type == "euro"
  25.     to_usd(value)
  26. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement