#include <math.h>
#include <stdio.h>
int loan( double n , double m , double l ){
int repayment = 0;
while( l > 0 ){
if( l - m > 0 ){
repayment = repayment + m;
}else{//
repayment = repayment + l;
}
l = (int) ( ( l - m ) * pow( 1 + n / 100.0 , 1 / 12.0 ) );
}
return( repayment );
}
void main(){
int l = 4500000;//initials borrowing
int m = 20000;//monthly repayment
double n = 5.0;//anual interest rate
int repayment = loan( n , m , l );
printf("Total = %d Yen \n", repayment );
}
but I was asked to change the program that able to find how much is the Monthly Repayment IF the Total Repayment is given which is 5,800,000 Yen.
I need to state the
1) idea of how to find the solution
2) the solution of the program
3) the result.
Thanks in advance for your help. I'm sorry for my bad English. I translated some of the language in the program because the original one was in Japanese.