**Sep 9: Added a note on mortgage rounding and corrected the due date.**

This assignment assumes that you have read up through Chapter 3. Please bring your book to lab, as you will need it as a reference.

The objectives for this assignment are:

mkdir cse20211/lab2 cd cse20211/lab2

* 1 2 3 4 5 1 1 2 3 4 5 2 2 4 6 8 10 3 3 6 9 12 15Note that each entry in the table is right-justified and occupies four characters, so that the numbers all line up. Consult Chapter 9.8 to see how to make printf use a field width of 4 for decimals. Test your program out to a very large number on the Y axis.

A mortgage is quite simple. The bank loans you a certain amount of money (the principal) to purchase a house at a certain interest rate.
Every month, you must make a payment to reduce the balance. In addition, the bank charges interest by computing one twelfth of the interest rate times the remaining balance, increasing the balance due. (Unfortunately, the interest gets charged *before* your payment is applied.

For example, suppose that you borrow $100,000 to purchase a home at 5 percent yearly interest. You agree to pay $500 per month until the mortgage is paid off. In the first month, the interest increases the balance by $416.67, then your payment reduces it by $500, for a remaining balance of $99,916.67. The first payment only reduced the principal by $83.33! (This is going to take a while.)

In the second month, the interest charge is $416.31, and the remaining balance is $99832.99. And so on. If you keep computing like this, you get what is known as an *amortization table* that shows every payment until the mortgage is paid off.

Month Payment Interest Balance 1 $500.00 $416.67 $ 99916.66 2 $500.00 $416.32 $ 99832.89 ... 430 $500.00 $ 3.97 $ 457.01 431 $458.84 $ 1.90 $ 0.00

Write a program called `mortgage.c` that asks the user to input the principal, interest rate, and desired monthly payment, and then displays an amortization table. At the end, the program should display how long it took to pay off the mortgage (in years and months) and the total amount of payments over that time. For example:

You paid a total of $215458.92 over 35 years and 11 months.

*(Note: These examples were calculated by using a float to represent
the balance, so you will notice some oddities in the rounding, as the
program is keeping track of sub-cent values. Your bank has some specific
rules for rounding off cents on each calculation, but we won't get into
that level of detail.)*

Once you have the basic calculation working, solve the following refinements:

Pick a non-trivial function with multiple maxima and minima that makes an interesting pattern. It could be a high-degree polynomial or some combination of transcendental functions. As a simple example, here is the output for 10.0*(1.0+sin(x)). Select a range that shows some interesting behavior. Again, use printf to limit the displayed precision and line up the columns nicely.

Turn in `table.c`, `mortgage.c`, `graph.c`, and `report.txt`. Your lab report should explain the final part of the assignment,
explaning how it works from the user perspective,
how the program works internally,
and how you verified that the output of the program is correct.

Please review the general instructions for turning in.