Reference no: EM13852132
Write a C program for the following problems. Be sure that your program follows the requirements described on the Style Requirements document found on Pilot.
Explanation of the problem:
Write a C program that calculates the monthly payment and amortization schedule for the loan. The program should prompt the user to enter the loan amount, the annual interest rate, and the number of years the loan will run. Use the formula below to calculate the monthly payment. Note that the user input for interest rate and term will be in years, but you will need monthly interest rate and term in months for this formula.
where P is the principal (loan amount), r is the monthly interest rate, and n is the number of months
Output: Display all information as shown on the sample program runs that follow. This includes the loan information (initial loan amount, annual interest rate, monthly interest rate, term of loan in years, term of loan in months, and monthly payment amount). Then display the amortization table and the total interest paid over the life of the loan.
The amortization table displays the loan balance at the beginning of each month, the monthly payment, the interest for the month (beginning monthly balance * monthly interest rate), the principal payment (loan balance - interest), and the new balance (beginning balance - principal payment). There should be an output line for each month over the life of the loan. So if a loan is for 5 years, there would be 60 lines of output.
Be sure to use functions for all main tasks. At a minimum, you need a function to calculate the monthly payment and a function to print the amortization table. You also need a function to calculate the monthly interest due; call this function from the function that prints the amortization table.
Be sure to use a validation loop for all input values (a separate loop for each). The principal and loan term (number of years) should be greater than 0. The annual interest rate should be between 0 and 30.
Note that the final payment on the loan may need to be adjusted to prevent a negative balance. Be sure to make this adjustment, if necessary, so that the final loan balance is 0.
Display all currency with two places to the right of the decimal; display all interest rate values with three places to the right of the decimal.
Once your program is working, add code so that the user is asked if he/she wants to run it again with new inputs. Repeat the processing steps until the user no longer wants to continue.