mortgage program
Kevin Carothers
kevin at ttidca.TTI.COM
Fri Jan 4 07:01:21 AEST 1991
In article <9101022144.AA13145 at hp370b.CFSMO.Honeywell.COM> bonl1 at CFSMO.HONEYWELL.COM (Boniface Lee #1) writes:
>
>Does anyone has a source program for mortgage payment calculations? I like
>to run it on my IBM PC...please e-mail the program...thanks!
>
>
>Boniface Lee (bonl1 at cfsmo.honeywell.com)
>Honeywell Commercial Flight Systems - Minneapolis Operations
--
Sure.
*I* work at CITIBANK :-) (But seriously, folks...)
just compile and run, and keep hitting cariage returns to get
monthly payment, interest, principal and balance info, and stop
bugging your loan officer.
I developed this on a PDP-11/70 (!!), and run it (with a couple of
silly lint errors) on my SPARC. Hope it helps.
--
/*
Program to print a mortgage payment
debt over a period of years
*/
#include <stdio.h>
main()
{
int c,i;
float mort_amt;
float mort_int;
float mort_pmt;
float intrst;
int mort_yrs;
float t_int;
float t_t;
float t_tmp;
float temp;
float tmp_amt;
float tmp_int;
int tmp_yrs;
int y_yrs;
float y_int;
float y_t;
float y_tmp;
printf("Enter the loan amount: ");
scanf("%f",&mort_amt);
printf("Enter the years of the loan: ");
scanf("%d",&mort_yrs);
tmp_yrs=mort_yrs;
printf("Enter the interest rate: ");
scanf("%f",&mort_int);
if(mort_int < 1.) mort_int *= 100.;
intrst = (mort_int/100.)/12.;
mort_yrs *= 12;
temp = 1.;
do {
temp *= (1. +intrst);
mort_pmt += (1./temp);
mort_yrs--;
} while(mort_yrs > 0);
temp = mort_amt/mort_pmt;
mort_int /= 100.;
y_tmp = y_int = y_t = 0.;
mort_yrs = 0;
tmp_amt = mort_amt;
printf("\nloan amount: $%6.2f\t\t",tmp_amt);
printf("loan rate: %4.2f%\n",mort_int*100.);
printf("monthly payment: $%10.2f\n\n",temp);
if((c=getchar()) != EOF)
if((c=getchar()) == EOF)
exit();
do {
printf("year: %d",++mort_yrs);
printf("\nloan amount: $%6.2f\t\t",tmp_amt);
printf("loan rate: %4.2f%\n",mort_int*100.);
printf("monthly payment: $%10.2f\n\n",temp);
printf("month\tpayment\t\tinterest\tprincipal\tbalance\n");
printf("-----\t-------\t\t--------\t---------\t-------\n");
t_tmp = t_int = t_t = 0.;
for(i=1 ; i <= 12 ; ++i) {
if(mort_amt <= .01) {
mort_yrs = tmp_yrs; /* force exit */;
break;
}
tmp_int = temp - (mort_amt*(mort_int/12.));
mort_amt -= tmp_int;
printf("%2d\t$%7.2f\t$%7.2f\t$%7.2f\t$%7.2f\n",
i,temp,temp-tmp_int,tmp_int,mort_amt);
t_tmp += temp;
t_t += tmp_int;
t_int +=temp-tmp_int;
y_tmp+= temp;
y_t += tmp_int;
y_int += temp-tmp_int;
}
printf(" \t_______\t\t________\t_________\n");
printf(" \t$%7.2f\t$%7.2f\t$%7.2f\n",t_tmp,t_int,t_t);
printf(" \t_______\t\t________\t_________\n");
printf(" \t$%7.2f\t$%7.2f\t$%7.2f\n",
y_tmp,y_int,y_t);
printf(" \t=======\t\t========\t=========\n");
if((c=getchar()) == EOF)
break;
} while(mort_yrs< tmp_yrs);
}
More information about the Alt.sources
mailing list