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

1. Exercise 6.7 (page 237) in the textbook. Requirements: a) You need to write t

ID: 3708747 • Letter: 1

Question

1. Exercise 6.7 (page 237) in the textbook.

Requirements: a) You need to write two classes for this problem. Name them Investment and InvestmentTest. The associated java files should be Investment.java and InvestmentTest.java. Make sure the two java files are saved at the same location on your computer.

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 rate) 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. futureInvestmentValue () – 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.pow(1 + monthlyInterestRate, years * 12)  

Note that monthlyInterestRate = annualRate / 12 2. printFutureValueTable () – print the future value table for 30 years.

d) Design the printing layout as close of the above example, for 30 years.

e) All the programming style and compiling requirements apply.  

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


Given below is the code for the question.
To indent code in eclipse , select code by pressing ctrl+a and then indent using ctrl+i
Please do rate the answer if it was helpful. Thank you


Investment.java
---------
public class Investment
{
public static double futureInvestmentValue(double investmentAmount, double monthlyInterestRate, int years)
{
double futureValue = investmentAmount * Math.pow(1 + monthlyInterestRate , years * 12) ;
return futureValue;
}

public static void printFutureValueTable(double investmentAmount, double yearlyInterestRate)
{
double val;
double monthlyInterestRate = yearlyInterestRate / 12;

System.out.printf("%-15s %15s ", "Years", "Future Value");

for(int i = 1; i <= 30; i++)
{
val = futureInvestmentValue(investmentAmount, monthlyInterestRate, i);
System.out.printf("%-15d %15.2f ", i, val);
}
}
}


InvestmentTest.java
===============
import java.util.Scanner;

public class InvestmentTest {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);

double investmentAmount;
double yearlyInterestRate;

System.out.print("Enter investment amount, for example 100: ");
investmentAmount = keyboard.nextDouble();

System.out.print("Enter yearly interest rate, for example 5.25: ");
yearlyInterestRate = keyboard.nextDouble();

yearlyInterestRate /= 100;
Investment.printFutureValueTable(investmentAmount, yearlyInterestRate);
}
}

output
======
Enter investment amount, for example 100: 10000
Enter yearly interest rate, for example 5.25: 3.75
Years Future Value
1 10381.51
2 10777.58
3 11188.76
4 11615.63
5 12058.78
6 12518.83
7 12996.44
8 13492.28
9 14007.02
10 14541.41
11 15096.18
12 15672.12
13 16270.03
14 16890.76
15 17535.16
16 18204.15
17 18898.66
18 19619.67
19 20368.19
20 21145.26
21 21951.98
22 22789.47
23 23658.92
24 24561.54
25 25498.59
26 26471.40
27 27481.32
28 28529.76
29 29618.21
30 30748.18