Professional Documents
Culture Documents
Assignment 2
Assignment 2
Assignment 2
Please paste the screenshots of your solution to this file and send the file to the email
vuducly151092@gmail.com
import datetime
class BankAccount:
def __init__(self, balance):
self.balance = balance
self.transactions = []
def view_balance(self):
return f"Current Balance: ${self.balance}"
def print_transactions(self):
return "\n".join(self.transactions)
account = BankAccount(1000)
while True:
print("1. Deposit money into the balance")
print("2. Withdraw money from the balance")
print("3. View current balance")
print("4. View balance change history")
print("5. Exit")
if choice == '1':
deposit_amount = float(input("Enter the amount you want to deposit
into the balance: "))
print(account.add_money(deposit_amount))
elif choice == '2':
withdraw_amount = float(input("Enter the amount you want to withdraw
from the balance: "))
print(account.subtract_money(withdraw_amount))
elif choice == '3':
print(account.view_balance())
elif choice == '4':
print(account.print_transactions())
elif choice == '5':
print("Thank you for using the banking service.")
break
else:
print("Invalid option. Please choose again.")