Answer:
def deposit(deposit_amount, balance):
balance += deposit_amount
return balance;
def process_check(check_amount, balance):
balance -= check_amount
return balance;
balance = float(input("Enter the initial balance: "))
transaction = input("Choose transaction method - D to deposit, C to process check, Q to quit: ")
while transaction != 'Q':
if transaction == 'D':
deposit_amount = float(input("Enter amount to be deposited: "))
balance = deposit(deposit_amount, balance)
print("Current balance is: " + str(balance))
elif transaction == 'C':
check_amount = float(input("Enter amount to process check: "))
if balance >= check_amount:
balance = process_check(check_amount, balance)
print("Current balance is: " + str(balance))
else:
print("Not enough money!")
else:
print("Invalid input!")
transaction = input("Choose transaction method - D to deposit, C to process the check, Q to quit: ")
print("Your final balance is: " + str(balance))
Explanation:
- Create functions to handle deposits and checks
- Ask the user for the initial balance and transaction to be made
- Initialize a while loop iterates until the user enter Q
- Ask the deposit amount or check amount depending on the transaction chosen
- Calculate and print the current balance for each transaction
- Print the final balance