Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that reads a bank account balance and an interest rate and displ

ID: 3627096 • Letter: W

Question

Write a program that reads a bank account balance and an interest rate and display the value of the account in ten years. The output should show the value of the account for 3 different methods of compounding interest: annually, monthly, and daily. Leap years are not taken into account. Also, not allowed to use an algebraic algorithim to compute the account balance, but instead must use a loop to compute the balances. I am only having problems with the loops. Will award maximum karma to whomever helps me understand how the loop(s) compute the interest rate, and I'd settle for just seeing the annual loop as that would help me figure out the other 2 loops.

Explanation / Answer

please rate - thanks

import java.util.*;
public class Main
{
public static void main(String[] args)
    {Scanner in= new Scanner(System.in);
    double balance,balanceSaved,rate,rateSaved;
    int year,month,day;
    System.out.print("Enter account balance: ");
    balance=in.nextDouble();
    balanceSaved=balance;
    System.out.print("Enter interest rate: ");
    rate=in.nextDouble();
    rate=rate/100.; //make a decimal
    rateSaved=rate;
    for(year=1;year<=10;year++)
           balance=balance+(balance*rate);
    System.out.println("balance after yearly compound= $"+balance);
    balance=balanceSaved;
    rate=rateSaved/12;    //make monthly
    for(month=1;month<=(12*10);month++)
           balance=balance+(balance*rate);
    System.out.println("balance after monthly compound= $"+balance);
   balance=balanceSaved;
    rate=rateSaved/365;   //make daily
    for(day=1;day<=(365*10);day++)
           balance=balance+(balance*rate);
    System.out.println("balance after daily compound= $"+balance);  
}
}