i hope im doing this right, im sorry i dont know anything about programming. This was my assignment:

/*

MAE9: Homeworki #3, Spring 2003

Due on Thursday, April 24, before 11:00 pm

Create a table for monthly payments of a house loans.

Enter the price of a house from the keyboard, for example

price = 450000.

For annual interest rates: annual_rate = 0.045 to 0.075 with

the increment of 0.0025, compute by using the for-loop the

monthly payments for 15-year, 20-year, and 30-year loans.

Print the results in the table on the screen.

Then, copy the previous loop and modify it to calculate the

total payments after 15, 20, and 30 years. Print results in

another table on the screen.

Use the formula for equal-monthly-payments:

month_pay = price * i* (1 + i)^n/((1 + i)^n - 1)

where i= annual_rate/12. (monthly interest rate),

and n = the total number of payments.

The total payment for a given loan is:

tot = n * month_pay

To compute (1 + i)^n use pow(1.0 + i, (double)n)

Your output should look like this:

price = 450000.00

Monthly Payments

Ann. Int. Rates 15-year loan 20-year loan 30-year loan

------------------------------------------------------------------

0.0450 3442.47 2846.92 2280.08

0.0475 3500.24 2908.01 2347.41

...... ....... ....... .......

0.0750 4171.56 3625.17 3146.47

Total Payment

Ann. Int. Rates after 15 yr after 20 yr after 30 yr

-----------------------------------------------------------------

0.0450 619644.56 683261.33 820830.20

0.0475 630043.85 697921.52 845068.69

...... ......... ......... .........

0.0750 750880.01 870040.65 1132727.50

*/

and this is my attempt:

Code:#include<stdio.h> #include<math.h> main() { printf("\t\t\tMonthly Payments\nAnn. Int. Rates\t15-year loan\t20-year loan\t30- year loan\n--------------------------------------------------------------\n"); int k; double r, m1, m2, m3, tot1, tot2, tot3, n, m, o, p, b; p=450000; n=180; m=240; o=360; for(k=1; k<=12; k++) { r = (.0450+(.0025*(k))),k; b = ("(r) /12."),r; m1 ={((p)*(b)*(1 + b) ^(n)}/{((1+b) ^(n)-1))}; m2 ={((p)*(b)*(1 + b) ^(m)}/{((1+b) ^(m)-1))}; m3 ={((p)*(b)*(1 + b) ^(o)}/{((1+b) ^(o)-1))}; tot1 = (n * m1); tot2 = (m * m2); tot3 = (o * m3); printf("\t%1.4f\n",r); } }