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

write a java program where Melanie who wants to start a college fund for her chi

ID: 3876524 • Letter: W

Question

write a java program where Melanie who wants to start a college fund for her children. She contemplates to invest some money in securities, but she needs a program to assist her in deciding how many years she has to invest. The program reads in the amount of initial investment, the amount of money needed for her children to go to college, and the projected annual return rate (in percent). The program then displays the minimum number of years needed to generate enough money for her children to go to college. A sample output looks like the one below:
Enter the amount of initial investment: 5000.00 Enter the amount of target college fund: 40000.00 Enter the projected annual return rate (in %): 8
If you invest $5,000.00 with 8.00 percent annual return rate, you have to invest at least 28 years to reach the target college fund. Your future investment value will be $43,135.53.

Explanation / Answer

TargetCollegeFund.java

import java.text.NumberFormat;

import java.util.Scanner;

public class TargetCollegeFund {

public static void main(String[] args) {

//Declaring variables

double initialAmt, targetFund, rate, interest, principal;

int years = 1, count = 0;

/*

* Creating an Scanner class object which is used to get the inputs

* entered by the user

*/

Scanner sc = new Scanner(System.in);

NumberFormat fmt = NumberFormat.getCurrencyInstance();

//Getting the input entered by the user

System.out.print("Enter the amount of initial investment: ");

initialAmt = sc.nextDouble();

System.out.print("Enter the amount of target college fund:");

targetFund = sc.nextDouble();

System.out.print("Enter the projected annual return rate (in %):");

rate = sc.nextDouble();

principal = initialAmt;

//Calculating the no of hours required to reach target fund

while (principal <= targetFund) {

interest = principal * (rate / 100) * years;

principal += interest;

count++;

}

//Displaying the output

System.out.println("If you invest " + fmt.format(initialAmt) + " with " + rate + " percent annual return rate, ");

System.out.println("you have to invest at least " + count + " years to reach the target college fund.");

System.out.println("Your future investment value will be " + fmt.format(principal) + ".");

}

}

________________

Output:

Enter the amount of initial investment: 5000.00
Enter the amount of target college fund:40000.00
Enter the projected annual return rate (in %):8
If you invest $5,000.00 with 8.0 percent annual return rate,
you have to invest at least 28 years to reach the target college fund.
Your future investment value will be $43,135.53.

_______________Could you plz rate me well.Thank You