Answer:
Step-by-step explanation:
Here's an example program in Python that fulfills the requirements:
# Get user inputs
annual_interest_rate = float(input("Enter the annual interest rate: "))
starting_balance = float(input("Enter the starting balance: "))
months = int(input("Enter the number of months since the account was established: "))
# Initialize variables
balance = starting_balance
total_deposits = 0.0
total_withdrawals = 0.0
total_interest_earned = 0.0
# Iterate through each month
for i in range(months):
# Get amount deposited and add to balance
deposit = float(input("Enter the amount deposited for month {}: ".format(i+1)))
while deposit < 0:
deposit = float(input("Amount deposited cannot be negative. Please enter again: "))
balance += deposit
total_deposits += deposit
# Get amount withdrawn and subtract from balance
withdrawal = float(input("Enter the amount withdrawn for month {}: ".format(i+1)))
while withdrawal < 0:
withdrawal = float(input("Amount withdrawn cannot be negative. Please enter again: "))
balance -= withdrawal
total_withdrawals += withdrawal
# Calculate monthly interest and add to balance
monthly_interest_rate = annual_interest_rate / 12
monthly_interest = balance * monthly_interest_rate
balance += monthly_interest
total_interest_earned += monthly_interest
# Write results to file
report_file = open("Report.txt", "w")
report_file.write("Ending Balance: ${:.2f}\\".format(balance))
report_file.write("Total Deposits: ${:.2f}\\".format(total_deposits))
report_file.write("Total Withdrawals: ${:.2f}\\".format(total_withdrawals))
report_file.write("Total Interest Earned: ${:.2f}\\".format(total_interest_earned))
report_file.close()
# Display message to user
print("Report written to Report.txt")
Note that the program validates user inputs to ensure that deposit and withdrawal amounts cannot be negative. The final results are written to a file named "Report.txt". The program prints a message to the user indicating that the report has been written.