Compute CD value

The problem

Suppose you put $10,000 into a CD with an annual percentage yield of 5.75%. After one month, the CD is worth 10000 + 10000 * 5.75 / 1200 = 10047.91. After two months, the CD is worth 10047.91 + 10047.91 * 5.75 / 1200 = 10096.06 After three months, the CD is worth 10096.06 + 10096.06 * 5.75 / 1200 = 10144.43 and so on. Write a program that prompts the user to enter an amount (e.g., 10000), the annual percentage yield (e.g., 5.75), and the number of months (e.g., 18) and displays a table

Breaking it down

public static void main(String[] strings) {

    Scanner input = new Scanner(System.in);

    System.out.print("Enter the initial deposit amount: ");
    double deposit = input.nextDouble();

    System.out.print("Enter annual percentage yield: ");
    double annualInterestYield = input.nextDouble();
    
    System.out.print("Enter maturity period (number of months): ");
    double maturityPeriod = input.nextInt();

    input.close();
    
    double monthlyInterestRate = monthlyInterestRate(annualInterestYield);
    
    System.out.print("Months\t\t\tCD Value\n");
    for (int i = 1; i <= maturityPeriod; i++)
    {
        deposit *= (1.0D + monthlyInterestRate);
        System.out.printf("%5d%20.2f\n", i, deposit);
    }
}

private static double monthlyInterestRate(double annualInterestYield) {
    double monthlyInterestRate = annualInterestYield / 1200.0;
    return monthlyInterestRate;
}

Output

Enter the initial deposit amount: 10000
Enter annual percentage yield: 5.75
Enter maturity period (number of months): 18
Months          CD Value
    1            10047.92
    2            10096.06
    3            10144.44
    4            10193.05
    5            10241.89
    6            10290.97
    7            10340.28
    8            10389.82
    9            10439.61
   10            10489.63
   11            10539.89
   12            10590.40
   13            10641.14
   14            10692.13
   15            10743.37
   16            10794.84
   17            10846.57
   18            10898.54