Bank Accounts

Imagine that you are a software engineer at a top-tier bank. The bank is working to improve their backend system, and your task is to design and implement new classes to represent different types of bank accounts.
The bank offers two types of accounts: checking and savings. Both types of accounts allow customers to deposit and withdraw money. But each type of account has its own characteristics. Checking accounts have an overdraft limit, which allows customers to withdraw money beyond their current balance up to the overdraft limit. Savings accounts earn interest based on an annual percentage yield.
Your task is to create three Python classes: BankAccount, CheckingAccount, and SavingsAccount. All of them are initialized with a starting balance amount.
  1. The BankAccount class should have two methods: deposit and withdraw. The deposit method should increase the balance by the amount of the deposit. The withdraw method should decrease the balance by the amount of the withdrawal. Both should print the final balance after the operation in the Balance: <X> format. If there aren’t sufficient funds, the program should print Insufficient funds..
  1. The CheckingAccount class should inherit from BankAccount and add an additional attribute: overdraft_limit. The withdraw method in CheckingAccount should be overridden to allow customers to withdraw money beyond their current balance up to the overdraft limit. In case of exceeding the overdraft limit, the program should print Withdrawal exceeds overdraft limit..
  1. The SavingsAccount class should also inherit from BankAccount. It should add an additional initialization attribute: annual_percentage_yield, and add a method calculate_returns that calculates the returns for saving money based on the annual_percentage_yield. The calculate_returns method should print the returns in the Returns: X format.
The balance in any account should never become negative (except for the CheckingAccount where it can go up to the negative overdraft limit).
Input
Output
check = CheckingAccount(500, 100); check.deposit(200); check.withdraw(800); saving = SavingsAccount(500, 0.05); saving.calculate_returns()
Balance: 700 Balance: -100 Returns: 25
 

Constraints

Time limit: 2 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue