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

my program is suppose to do this Write a program that prompts the user for a beg

ID: 3543307 • Letter: M

Question

my program is suppose to do this

Write a program that prompts the user for a beginning bank balance and an interest rate. The program will display the value of the account at the end of each year for 10 years. The output should show the value of the account for three different methods of compounding interest:

i have this as my program but i need to know how to show the annual interest every year instead of every 10 years. what do i need to do to make it right

import java.util.Scanner;

public class BankInterest {

public static final int YEARS = 10;

public static final int MONTHS = 12;

public static final int DAYS = 365;

public static void main(String[] args)

{

double balance;

double interestRate;

double annualBalance;

double monthlyBalance;

double dailyBalance;

double value;

int year;

String choice;

Scanner input = new Scanner(System.in);

do

{

System.out.print("Enter the balance: $");

balance = input.nextDouble();

System.out.println("Enter the interest rate: ");

interestRate = input.nextDouble();

value = 1;

year = 0;

while(year < YEARS)

{

value = value * (1.0 + (interestRate/100.0));

year++;

}

annualBalance = balance * value;

value = 1;

year = 0;

while(year < (YEARS * MONTHS))

{

value = value * (1.0 + ((interestRate/

12.0)/ 100.0));

year++;

}

monthlyBalance = balance * value;

value = 1;

year = 0;

while(year < (YEARS * DAYS))

{

value = value * (1.0 +((interestRate/

365.0)/100.0));

year++;

}

dailyBalance = balance * value;

annualBalance = Math.round(annualBalance *

100.0)/100.0;

monthlyBalance = Math.round(monthlyBalance *

100.0)/100.0;

dailyBalance = Math.round(dailyBalance *

100.0)/100.0;

System.out.println("The initial balance: $"

+ balance);

System.out.println("The rate of interest: $"

+ interestRate);

System.out.println("The number of years: "

+ YEARS);

System.out.println("The value of account compounded "

+ "annually: $" + annualBalance);

System.out.println("The value of account compounded "

+ "monthly: $" + monthlyBalance);

System.out.println("The value of account compounded "

+ "daily: $" + dailyBalance);

System.out.print("Do you want to repeat the process?"

+ "(y/n): ");

choice = input.next();

System.out.println();

}while(choice.equalsIgnoreCase("y"));

}

{

Explanation / Answer



import java.util.Scanner;


public class BankInterest {


public static final int YEARS = 10;


public static final int MONTHS = 12;


public static final int DAYS = 365;


public static void main(String[] args)


{


double balance;


double interestRate;


double annualBalance;


double monthlyBalance;


double dailyBalance;


double value;


int year;


String choice;


Scanner input = new Scanner(System.in);


do


{


System.out.print("Enter the balance: $");


balance = input.nextDouble();


System.out.println("Enter the interest rate: ");


interestRate = input.nextDouble();


value = 1;


year = 0;

System.out.println("The initial balance: $"


+ balance);


System.out.println("The rate of interest: $"


+ interestRate);


System.out.println("The number of years: "


+ YEARS);


while(year < YEARS)


{


value = value * (1.0 + (interestRate/100.0));


year++;

System.out.printf("The value of account compounded annually after %d years is $%.2f ", year, value * 100);


}


System.out.printf(" ");

annualBalance = balance * value;


value = 1;


year = 0;


while(year < (YEARS * MONTHS))


{


value = value * (1.0 + ((interestRate/


12.0)/ 100.0));


year++;

if(year % MONTHS == 0) System.out.printf("The value of account compounded monthly after %d years is $%.2f ", year / MONTHS, value * 100);

}


monthlyBalance = balance * value;


value = 1;


year = 0;


System.out.printf(" ");

while(year < (YEARS * DAYS))


{


value = value * (1.0 +((interestRate/


365.0)/100.0));


year++;

if(year % DAYS == 0) System.out.printf("The value of account compounded daily after %d years is $%.2f ", year / DAYS, value * 100);


}


dailyBalance = balance * value;


annualBalance = Math.round(annualBalance *


100.0)/100.0;


monthlyBalance = Math.round(monthlyBalance *


100.0)/100.0;


dailyBalance = Math.round(dailyBalance *


100.0)/100.0;









System.out.print("Do you want to repeat the process?"


+ "(y/n): ");


choice = input.next();


System.out.println();


}while(choice.equalsIgnoreCase("y"));


}


}