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

Enter investment amount, for example 100: 10000 Enter yearly interest rate, for

ID: 3705078 • Letter: E

Question

Enter investment amount, for example 100: 10000 Enter yearly interest rate, for example 5.25: 3.75 Years 6.7Fancial ompue the re imestment value) Wrise a method thn Future Value 10381.51 10777.58 11188.76 11615.63 12058.78 12518.83 12996.44 13492.28 14007.02 4541.41 15096.18 15672.12 16270.03 16890.76 7535.16 18204-15 18898.66 compuies future investment value at a given interest rate for a specified numbee of yeas The fture lovestenent is desermined using the formula in Programming Exercise 221 Use the following method header public static double futureinvesteent Value ( double investeentAmount, double monthlyinterestRate, 1nt years) For esample. futureIovesteentValue (10000, 0.05112, 5) returns 12833. 58. Write a test program that prompts the aser to enter the investment amoust (eg. 1,000) and the interest rate (4,9%)and prints a uble that displays future value for the years from I to 30, as shown beow: 10 ajYou need to write two classes for this problem. Name them Investment and InvestmentTest. The associated java files should be Investment.java and nvestmentTest.java. Make sure the two java files are saved at the same location on your computer. 12 13 14 15 16 17 b) The InvestmentTest class should contain only a main method. In this main method, the program takes user inputs of three values-investmentAmount in double, annualRate (annual interest ratej in double, and years in integer. The main method should also invoke a method from the Investment class to print the future value table for 30 years. c) The Investment class should contain two methods. 1. futurelnvestmentValue - use three parameters (investmentAmount, monthlyinterestRate, and years) to calculate and return the future value. The formula to calculate the future value is futureValue investmentAmount Math powfl+ monthlyinterestRate, years* 12) Note that monthlyinterestRate annualRate / 12 2. printFutureValueTable 0 print the future value table for 30 years. The table should look like the one below d) Design the printing layout as close of the above example, for 30 years.

Explanation / Answer

Investment.java

class Investment
{
   //method to calculate future value
   public static double futureInvestmentValue(double investmentAmount,double monthlyInterestRate,int years)
   {
       double futureValue = investmentAmount*Math.pow(1+monthlyInterestRate,years*12);//please verify formula again
       return futureValue;//return
   }
   //printing future values for 30 years
   public static void printFutureValueTable(double investmentAmount,double annualInterestRate,int years)
   {
       double monthlyInterestRate=annualInterestRate/12;//monthly interest rate
       System.out.println("Years FutureValue ");
       for(int year=1;year<=30;year++)//for 30 years
       {
               double futureValue=futureInvestmentValue(investmentAmount,monthlyInterestRate,year);//invoking method
               System.out.println(year+" "+futureValue);
       }
   }
}

InvestmentTest.java

import java.util.Scanner;//to get input data from user
class InvestmentTest
{
       public static void main(String args[])//main method
       {
           Scanner input = new Scanner(System.in);
           double investmentAmount,annualInterestRate;
           int years;
           System.out.println("Enter Investment Amount:");//prompt user to enter investment amount
           investmentAmount=input.nextDouble();
           System.out.println("Enter Annual Interest rate:");//prompt user to enter interest rate
           annualInterestRate=input.nextDouble();
           System.out.println("Enter number of years:");//prompt user to enter number of years
           years=input.nextInt();
          
           Investment obj = new Investment();//creating object for Investment class
           obj.printFutureValueTable(investmentAmount,annualInterestRate,years);//invoke printFutureValueTable method
       }
}