Calculation of interest and ending balance