PYTHON   43
account test
Guest on 27th August 2023 06:07:10 AM


  1. # This program demonstrates the BankAccount class
  2. # with the __str__ method added to it.
  3.  
  4. import bankaccount2
  5.  
  6. def main():
  7.     # Get the starting balance.
  8.     start_bal = float(input('Enter your starting balance: '))
  9.  
  10.     # Create a BankAccount object.
  11.     savings = bankaccount2.BankAccount(start_bal)
  12.  
  13.     # Deposit the user's paycheck.
  14.     pay = float(input('How much were you paid this week? '))
  15.     print('I will deposit that into your account.')
  16.     savings.deposit(pay)
  17.  
  18.     # Display the balance.
  19.     print(savings)
  20.  
  21.     # Get the amount to withdraw.
  22.     cash = float(input('How much would you like to withdraw? '))
  23.     print('I will withdraw that from your account.')
  24.     savings.withdraw(cash)
  25.  
  26.     # Display the balance.
  27.     print(savings)
  28.  
  29. # Call the main function.
  30. main()

Raw Paste

Login or Register to edit or fork this paste. It's free.