recursive code in java for calculation of money account in a bank -
i want implement recursive code in java calculation of money account in bank after years of investing ... here code
public static double computecapital(double capital, int years, double interestrate) { if (years == 0) { return capital; } else { double newcapital = capital * math.pow(interestrate,year); return computecapital(newcapital , years+1 , interestrate); } } is code correct? thanks
public static double computecapital(double capital, int years, double interestrate) { if (years == 0) { return capital; } else{ return computecapital(capital, years-1, interestrate)*(1+interestrate); } }
Comments
Post a Comment