Question: Hello I have a question that correlates to the code down below. The codes purpose is to compute future investment value. I did this in

Hello I have a question that correlates to the code down below. The codes purpose is to compute future investment value. I did this in eclipse. The question is this :

Testing: (Describe how you test this program)

Here is the Code:

package Investment.util;

public class Investment { public static void main(String[] args) { Scanner input = new Scanner(); // Create a Scanner final int NUMBER_OF_YEARS = 30; // Number of years to display

// Prompt the user to enter the investment amount and interest rate System.out.print(" The amount invested: "); double amount = input.nextDouble(); System.out.print("Annual interest rate: "); double annualInterestRate = input.nextDouble();

// Get monthly interest rate double monthlyInterestRate = annualInterestRate / 1200;

// Print a table that displays future value for the years from 1 to 30 System.out.println("Years Future Value"); // Table header for (int years = 1; years <= NUMBER_OF_YEARS; years++) { System.out.printf("%-10d", years); System.out.printf("%11.2f ", futureInvestmentValue(amount, monthlyInterestRate, years)); } }

/** Method futureInvestmentValue computes future investement value */ public static double futureInvestmentValue( double investmentAmount, double monthlyInterestRate, int years) { return investmentAmount * Math.pow(1 + monthlyInterestRate, years * 12); } }

Here is the Code:

package Investment.util;

public class Investment { public static void main(String[] args) { Scanner input = new Scanner(); // Create a Scanner final int NUMBER_OF_YEARS = 30; // Number of years to display

// Prompt the user to enter the investment amount and interest rate System.out.print(" The amount invested: "); double amount = input.nextDouble(); System.out.print("Annual interest rate: "); double annualInterestRate = input.nextDouble();

// Get monthly interest rate double monthlyInterestRate = annualInterestRate / 1200;

// Print a table that displays future value for the years from 1 to 30 System.out.println("Years Future Value"); // Table header for (int years = 1; years <= NUMBER_OF_YEARS; years++) { System.out.printf("%-10d", years); System.out.printf("%11.2f ", futureInvestmentValue(amount, monthlyInterestRate, years)); } }

/** Method futureInvestmentValue computes future investement value */ public static double futureInvestmentValue( double investmentAmount, double monthlyInterestRate, int years) { return investmentAmount * Math.pow(1 + monthlyInterestRate, years * 12); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!