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

1. public static double investmentValue(double amount, double interest, int numY

ID: 3702259 • Letter: 1

Question

1. public static double investmentValue(double amount, double interest, int numYears)

Write a recursive method that takes as parameters an initial investment amount, an annual interest rate, and a number of years. The method should return the value of the investment after the given number of years, assuming that the interest is compounded annually. (For example, if the initial investment is 1000 and the interest rate is 10 percent, then after one year the investment will be worth 1100, after two years 1210, after three years 1331, etc)

Explanation / Answer

public static double investmentValue(double amount,double interest,int numYears)
   {
       if(numYears>0)
       {
           amount = amount* (100+interest)/100;
           numYears--;
           return investmentValue(amount,interest,numYears);
       }
       else
       {
           return amount;
       }
   }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote