Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
02-09-2012, 10:43 PM #1
- Join Date
- Oct 2011
- Thanked 0 Times in 0 Posts
How can I calculate the balance with this formula in java program
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?
balance = dollars * Math.pow((1 + interestRate), years);
02-10-2012, 05:22 PM #2
years does need to be in double form- whether you convert or cast in this situation i think depends on your style since double is more precise than int and there should be no chance of data loss (I could be wrong though)
Edit: Math.pow(double a, double b) is expected