Path: utzoo!utgpu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!sdd.hp.com!spool2.mu.edu!marque!joeb From: joeb@marque.mu.edu Newsgroups: alt.sources Subject: Re: mortgage program (source) Message-ID: <10035@marque.mu.edu> Date: 3 Jan 91 18:40:28 GMT References: <9101022144.AA13145@hp370b.CFSMO.Honeywell.COM> Sender: usenet@marque.mu.edu Reply-To: joeb@marque.mu.edu (Joe Bronikowski) Organization: Marquette University - Milwaukee, Wisconsin Lines: 90 Approved: usenet@marque.mu.edu Here's a simple little mortgage calcuator program. It prints tables of monthly payments for different principals and different interest rates; tables are printed for 15-year and 30-year mortgages. You can optionally include a specific principal amount in the table by including it on the command line. If desired, it should be easy to include a specific interest rate also. Have fun! ------------------------------------------------------------------------ /* ** Compute monthly mortgage payments for 15 and 30 year mortgages, at ** various interest rates. Expects tab stops every 8 characters. ** ** Usage: mortgage [amount] */ #define P_LOW 50000 /* range of principal */ #define P_HIGH 200000 #define P_INCR 25000 #define Y_LOW 15 /* range of mortgage terms */ #define Y_HIGH 30 #define Y_INCR 15 #define R_LOW .085 /* range of interest rates */ #define R_HIGH .125 #define R_INCR .005 double pow(double,double); main(argc,argv) int argc; char *argv[]; { int principal, years, amount = 0; float rate; char did_it; if (argc > 1) { if (argv[1][0] == '?') { usage(); exit(1); } amount = atoi(argv[1]); } for (years=Y_LOW; years<=Y_HIGH; years+=Y_INCR) { printf("\n\t\tMonthly Payment, %d-year mortgage\n",years); printf("Principle\t\tInterest Rate\n"); for (rate=R_LOW; rate P_HIGH)) ) { one_line(amount,years); did_it++; } if (principal <= P_HIGH) one_line(principal,years); } } } usage() { printf("Mortgage payment calculator\n\n"); printf("Usage: mortgage [amount]\n"); } one_line(amount,years) int amount; int years; { float rate; printf("$%6d",amount); for (rate=R_LOW; rate