Answer:
- init_balance = float(input("Enter initial balance: "))
- interest = float(input("Enter the annual interest rate in percent: "))
- monthly_interest = (interest / 100) / 12
- current_amount = init_balance + init_balance * monthly_interest
- print("Balance after first month: %.2f " % current_amount)
- current_amount = current_amount + current_amount * monthly_interest
- print("Balance after second month: %.2f " % current_amount)
- current_amount = current_amount + current_amount * monthly_interest
- print("Balance after third month: %.2f " % current_amount)
Explanation:
The following code is written in Python.
First, prompt the user to input the initial balance and annual interest rate (Lines 1-2).
Next, derive the monthly interest rate by dividing the annual interest by 100 and then by 12 (Line 4).
The calculations for the current amount are applied, adding the monthly interest (Line 5) and displaying the balance after the first month (Line 6).
This procedure is repeated to compute amounts for the second and third months, followed by printing the results to the console (Lines 8-12).