sabi

02-09-2012, 09:43 PM

If you deposit p dollars, the money in your account after n years at an interest rate r is p (1 + r)^n

This is what I got.... Is this correct? and would I need to cast this beacause years are in int variable?

double balance;

double dollars;

double interestRate;

int years;

balance = dollars * Math.pow((1 + interestRate), years);

This is what I got.... Is this correct? and would I need to cast this beacause years are in int variable?

double balance;

double dollars;

double interestRate;

int years;

balance = dollars * Math.pow((1 + interestRate), years);