Answer:
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter the initial balance: ");
double initialBalance = input.nextDouble();
System.out.print("Enter the annual interest rate: ");
double annualInterestRate = input.nextDouble();
double monthlyInterest = (annualInterestRate / 100) / 12;
double currentBalance = initialBalance + (initialBalance * monthlyInterest);
for(int month=1; month<=3; month++){
System.out.printf("Your balance after " + month + ". month: %.2f \n", ((initialBalance + (initialBalance * monthlyInterest)* month)));
}
}
}
Explanation:
* The code is written in Java
- Ask user to enter initial balance and annual interest rate
- Calculate the monthly interest
- Calculate the current balance
- Print the value of the balance after first three months using for loop