crap_the_coder

Untitled

Apr 21st, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.06 KB | None | 0 0
  1. class ATM:
  2.     def __init__(self):
  3.         self.balance = 150.0
  4.  
  5.     def transaction(self, amount):
  6.         if amount % 10 != 0:
  7.             print('Transaction Error')
  8.             return
  9.  
  10.         if amount > self.balance - 0.5:
  11.             print('Insufficient funds')
  12.             return
  13.  
  14.         self.balance -= amount
  15.         self.balance -= 0.5
  16.  
  17.         print(f'Balance: {self.balance}')
  18.  
  19.     def run(self):
  20.         while True:
  21.             try:
  22.                 amount = float(input('Please enter the amount: '))
  23.                 self.transaction(amount)
  24.             except:
  25.                 print('Transaction Error')
  26.  
  27.             print()
  28.             again = input('Do you want to perform another transaction (Y/N): ').lower()
  29.  
  30.             while again not in ['y', 'n']:
  31.                 print('Please enter (Y/N)')
  32.                 again = input('Do you want to perform another transaction (Y/N): ').lower()
  33.  
  34.             if again == 'n':
  35.                 break
  36.  
  37.             print()
  38.  
  39.         print('Please take your card out')
  40.  
  41. atm = ATM()
  42.  
  43. atm.run()
Add Comment
Please, Sign In to add comment