Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. '''
  2. This is a currency exchanger between Japanese Yen and US dollars.
  3. The exchanger works both ways.
  4. Asks which way the user would like to exchange, then the amount of money they have, and finally the code prints out the value of that amount of money.
  5. '''
  6. usd = 1
  7. yen = 111.44
  8. numbers = ['1','2','3','4','5','6','7','8','9','0']
  9. print("Welcome to the Japanese Yen to United States' Dollar Currency Exchanger.\n")
  10. way = input("Would you like to change Japanese yen into US dollars, or the other way around? \nPlease type a 1, for Yen to US dollars, and a 2 for US dollars into Yen. ")
  11. print("")
  12. if way.lower() != "1" or "2":
  13. while way.lower() != "1" or way.lower() != "2":
  14. if way.lower() == "1" or way.lower() == "2":
  15. break
  16. way = input("Please type a 1, for Yen to US dollars, and a 2 for US dollars into Yen. ")
  17.  
  18. money = input("How much money do you have? ")
  19. def checkMoney(money):
  20. '''
  21. (str) -> (str)
  22.  
  23. Checks to make sure that there are no weird characters.
  24. '''
  25. for x in money:
  26. if x not in numbers:
  27. money = input("How much money do you have? ")
  28. checkMoney(money);
  29.  
  30. checkMoney(money);
  31. print(money)
  32. money = float(money)
  33.  
  34. def ytd(money):
  35. '''
  36. (float) -> (float)
  37.  
  38. Turns Japanese Yen into United States' Dollars.
  39. '''
  40. amount = money / yen
  41. amount *= 100
  42. amount = int(amount)
  43. amount /= 100
  44. print(amount)
  45.  
  46. def dty(money):
  47. '''
  48. (float) -> (float)
  49.  
  50. Turns United States' Dollars into Japanese Yen.
  51. '''
  52. amount = money * yen
  53. amount = int(amount)
  54. print(amount)
  55.  
  56. if way.lower() == "1":
  57. ytd(money);
  58.  
  59. elif way.lower() == "2":
  60. dty(money);
  61.  
  62. else:
  63. print("error")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement