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 :
Design:
(Describe the major steps for solving the problem.)
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started