Write a java program called ComputeCDValue that takes an initial deposited CD am
ID: 3758675 • Letter: W
Question
Write a java program called ComputeCDValue that takes an initial deposited CD amount, an annual percentage yield, and a maturity period in months, and that prints out the CD's value at the end of each of the months in its maturity period (rounded to two decimal places).
You will calculate each month incrementally, using the total computed from the previous month. For instance, suppose the user gives you the number 10000 as the inital deposit into the CD, with an annual percentage yield of 5.75% (which is an increase of 5.75/100 * 1/12 each month, or 5.75/1200).
After one month, the CD is worth:
After two months, the CD is worth:
After three months, the CD is worth:
Using this formula, if given the inputs shown below, your program should have the following sample run:
Explanation / Answer
import java.util.Scanner;
public class Deposit
{
public static void main (String [] args)
{
double InitialDeposit = 0;
Scanner input = new Scanner(System.in);
System.out.println("Please Enter The intial Deposit Amount or Hit 0 and Enter to exit: ");
InitialDeposit = input.nextDouble();
while (InitialDeposit > 0)
{
System.out.println("Please Enter The Annual Percentage yield: ");
double annualPercentage = input.nextDouble();
System.out.println("Please Enter The Maturity period: ");
double Maturity = input.nextDouble();
System.out.println("Month CD Value ");
for ( int value= 1; value <= Maturity; value++)
{
InitialDeposit = InitialDeposit + InitialDeposit * (annualPercentage / 1200);
System.out.printf("%-15d%- 3.2f ", value, InitialDeposit);
}
System.out.println("Please Enter The intial Deposit Amount or Hit 0 to exit: ");
InitialDeposit = input.nextDouble();
}
if ( InitialDeposit == 0)
{
System.out.println(" Thank you for Depositing... Good Bye!");
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.