C program...mortgage?
Given an initial loan amount, an annual percentage rate (APR), an introductory and standard payment amount, and the introductory period in years, write a C program that computes and prints the interest accumulated and the remaining balance at the end of each yearly cycle. The program should continue printing the yearly values until the debt is paid off (i.e. the remaining balance becomes zero). Your program output should look as follows (user input in bold italics): Note: For all dollar amounts print out exactly 2 digits after the decimal point. Also ensure that all the numbers in the output table line up nicely so that the decimal points are all at the same column position. Also, for the last month, the payment need only be as much as the remaining debt. In the example, the last month’s payment is $23777.32 instead of $24000.00. The first column ‘Year’ keeps count of the number of years as the remaining debt diminishes each yearly cycle. The second column ‘Balance’ is the balance on the mortgage at the beginning of each yearly cycle. For the first year, the balance is the value input by the user at the beginning of the program. For subsequent years, the balance is calculated using the following formula: Balance = ‘New Balance’ from the previous year. The third column ‘Interest’ is the interest accrued on the ‘Balance’ at the end of each yearly cycle. It is calculated using the formula: Interest = balance*(APR/100). The fourth column is the ‘Payment’ at the end of each yearly cycle. In our program, this will be a constant value that the user inputs at the beginning and will change depending on if the mortgage is in its intro period. Hint: since the user inputs the monthly payment and your calculations use yearly payments, be sure to convert these values right after the user inputs them. For example, $500 monthly becomes $6000 yearly, and $2000 monthly becomes $24000 yearly. The fifth column is the ‘New Balance’ at the end of each monthly cycle. It is calculated using the following formula: New Balance = Balance + Interest – Payment. Once again, the payment value will depend on if the mortgage is in the intro or non-intro period, and if it is the final payment. Important: Your program must be able to catch negative amortization in the standard payment. This is, you must make sure that the standard payment is larger than the interest accumulated each month. In the above example, if the standard payment is $1000 (yearly $12000) you can clearly see that it is not enough to keep up with the interest. If this is the case, you must exit the program and print: Error: Loan is in negative amortization! Please help.
|