public class FutureInvestmentValue {

public static void main(String[] args) {
Scanner input= new Scanner (System.in);
System.out.print("Enter investment amount: ");
double investmentAmount = input.nextDouble();
System.out.print("Enter annual interest rate: ");
double annualInterestRate = input.nextDouble();
System.out.print("Enter the number of years: ");
double years = input.nextDouble();

double monthlyInterestRate = (annualInterestRate)/1200;
double investmentValuepart1 = (1 +monthlyInterestRate);
double investmentValuepart2 = (years *12);
double investmentValuepart3 = Math.pow(investmentValuepart1, investmentValuepart2);
double futureInvestmentValue = investmentAmount*investmentValuepart3;
System.out.printf("Accumulated value is: %.2f"+futureInvestmentValue);
}
}

the inputs work fine but when this program is displaying futureInvestmentValue, it gives an error. can someone help find the error?

5 answers

this is the assignment question:

Write a program that reads in investment amount, annual interest rate, and number of years, and displays the future investment value using the following formula:
and displays the future investment value using the following formula:

futureInvestmentValue =
investmentAmount * (1 + monthlyInterestRate)numberOfYears*12

For example, if you enter amount 1000, annual interest rate 3.25%, and number of years 1, the future investment value is 1032.98.

Hint: Use the Math.pow(a, b) method to compute a raised to the power of b.
Check for commas, colons and extra spaces : )
I got the error, it was:
System.out.printf("Accumulated value is: %.2f"+futureInvestmentValue);

the plus sign that is in front of futureInvestmentValue should be comma like
System.out.printf("Accumulated value is: %.2f",futureInvestmentValue);
can someone the code if its good?

public class FutureInvestmentValue {
public static void main(String[] args) {
Scanner input= new Scanner (System.in);
System.out.print("Enter investment amount: ");
double investmentAmount = input.nextDouble();
System.out.print("Enter annual interest rate: ");
double annualInterestRate = input.nextDouble();
System.out.print("Enter the number of years: ");
double years = input.nextDouble();

double monthlyInterestRate = (annualInterestRate)/1200;
double investmentValuepart1 = (1 +monthlyInterestRate);
double investmentValuepart2 = (years *12);
double investmentValuepart3 = Math.pow(investmentValuepart1, investmentValuepart2);
double futureInvestmentValue = investmentAmount*investmentValuepart3;
System.out.printf("Accumulated value is: %.2f", futureInvestmentValue);
}
}
yes, someone can check it -- you!
Run the dang program and see whether it produces the correct result!
Similar Questions
  1. import java.util.Scanner;public class Initials { public static void main(String[] args) { Scanner input = new Scanner
    1. answers icon 2 answers
  2. import java.util.Scanner;public class main { public static void main(String[] args) { Scanner wins = new Scanner(System.in);
    1. answers icon 0 answers
  3. public class SwitchCases {public static void main(String[] args) { Scanner input = new Scanner (System.in);
    1. answers icon 1 answer
  4. how do i add prime numbers in this java code:public class PrimeNumbers { public static void main(String[] args) { int[] array =
    1. answers icon 2 answers
more similar questions