I have completed the program but the calcutaltions are wrong do you see anything
ID: 3619865 • Letter: I
Question
I have completed the program but the calcutaltions are wrong do you see anything wrong with it? For an example if you type in 1000 for investment amount, 4.25 for interest rate, 1 for years the accumulated value should be 1043.34 but here is what i have.import java.util.Scanner;
public class ex2_3 {
public static void main(String[] args) {
// Create a Scanner
Scanner input = new Scanner(System.in);
// Enter investment amount
System.out.print("Enter investment amount: ");
int investmentAmount = input.nextInt();
// Enter interest rate
System.out.print("Enter monthly interest rate: ");
double monthlyInterestRate = input.nextDouble();
// Enter number of years
System.out.print("Enter number of years: ");
int numberOfYears = input.nextInt();
// Calculate payment
double futureInvestmentValue = investmentAmount * Math.pow(1 + monthlyInterestRate, numberOfYears * 12);
// Display results
System.out.println("Accumulated value is: " + (double)(futureInvestmentValue));
}
}
Explanation / Answer
Hi, The formula mentioned below is correct one. double futureInvestmentValue = investmentAmount * Math.pow(1 + (monthlyInterestRate / 100) , numberOfYears * 12); According to the above formula, your investment will be accumulated monthly wise and finally you will get 1647.83 for the input provided.
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.