Posted By

shaunchapman on 04/09/09


Tagged

money checking calculate how account bank Savings Interest how-to earned


Versions (?)

How To Calculate Interest Earned In A Bank Account


 / Published in: PHP
 

The interest rate banks pay is usually a yearly percentage. So, if your bank tells you that you're getting 4% interest and you start with $20,000 in your account, you would earn an extra $800 at the end of the year ($20,000 x 0.04 = $800).

However, it's not that simple. The interest you earn is usually compounded daily and paid monthly. This means the interest you earn on one day will be added to your original balance, which in turn earns interest the next day.

To calculate this, we take the $800 from above and divide it by 365 to figure out how much interest you would earn the first day ($800 / 365 = $2.19). So, you would earn $2.19 in interest on the first day. This $2.19 is then added to your original balance ($20,000 + $2.19 = $20,002.19). Remember when I said the bank pays you monthly? This means that this new balance of $20,002.19 is used in the calculation for tomorrow's interest however you won't actually get the money in your account until the end of the month. All this means is the bank doesn't have to put a couple dollars into your account every single day. You're still getting the same amount of money.

To calculate the interest earned the next day, you would do the same calculation but with the new balance ($20,0002.19 x 0.04 / 365). Can you see how your interest earned will increase each day? That's the beauty of compound interest.

In this case, the interest you would earn in 1 year is not $800 like in our original calculation. The amount of interest you would actually earn is $816.17.

  1. // Change these values
  2. $original_deposit = 4000;
  3. $interest_rate = 2.0; // Percent
  4. $number_of_years = 1;
  5.  
  6. // Initializations
  7. $total = $original_deposit;
  8. $earned_interest = 0;
  9.  
  10. // Loop through each day
  11. for ($i = 0; $i < ($number_of_years * 365); $i++) {
  12. // Find today's interest, which will be added to the total
  13. // This is where compound interest takes place
  14. // This means interest earned each day in turn earns interest :)
  15. $todays_interest = ($total * ($interest_rate / 100)) / 365;
  16. $total += $todays_interest;
  17.  
  18. // For outputting stats only; not use in calculation
  19. $earned_interest += $todays_interest;
  20. }
  21.  
  22. // Output stats
  23. echo 'Original deposit: $' . number_format($original_deposit, 2) . "\n";
  24. echo "Interest rate: $interest_rate%\n";
  25. echo "Number of years: $number_of_years\n\n";
  26. echo 'Earned interest: $' . number_format($earned_interest, 2) . "\n";
  27. echo 'End total: $' . number_format($total, 2) . "\n";

Report this snippet  

You need to login to post a comment.