Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ATM:
- def __init__(self):
- self.balance = 150.0
- def transaction(self, amount):
- if amount % 10 != 0:
- print('Transaction Error')
- return
- if amount > self.balance - 0.5:
- print('Insufficient funds')
- return
- self.balance -= amount
- self.balance -= 0.5
- print(f'Balance: {self.balance}')
- def run(self):
- while True:
- try:
- amount = float(input('Please enter the amount: '))
- self.transaction(amount)
- except:
- print('Transaction Error')
- print()
- again = input('Do you want to perform another transaction (Y/N): ').lower()
- while again not in ['y', 'n']:
- print('Please enter (Y/N)')
- again = input('Do you want to perform another transaction (Y/N): ').lower()
- if again == 'n':
- break
- print()
- print('Please take your card out')
- atm = ATM()
- atm.run()
Add Comment
Please, Sign In to add comment