Math problem in c++ program ugh. :)

I have a function to determine the monthly payment on user input loan amount, interest rate, and length in months.
1
2
3
4
5
6
7
double calcPayment(double Principle, double Rate, double Term) {

  
  double MonthlyRate = Rate/12.0/100; 
  double t = pow((1 + MonthlyRate),Term); 
  double Payment = (Principle * MonthlyRate * t) / (t-1); //
  return(Payment); 


Now I need to add a function to determine interest paid for life of loan.
Which is where I'm just not hitting my stride.
I assumed incorrectly that it would be length of loan * interest rate * monthly payment.

This is not for my homework or anything like that, I give you my word (how many people you hear say that?) What it's for is my wife pseudo-code program that I want to write in c++ and while her teacher says the math doesn't matter, she just wants to see proper use of functions, I do care and want to know.

Should I, perhaps, run the quoted code in a loop while counting down until the loan is paid off and keeping track of the amount of interest paid per month as I go? I know this might be off topic and apologies if it is too far 'off'.
The total amount of interest paid over the life of the loan is equal to the monthly payment times the number of
payments minus the loan amount.
Topic archived. No new replies allowed.