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

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -