Loan Application - Amortization Schedule Principal: Life of Loan (10, 15 or 30 years): Annual interest rate: Monthly payment: 100000 15 4.5% 764.99 Payment Amount Interest Principal Balance 100000.00 764.99 375.00 389.99 99610.01 2 764.99 373.54 391.46 99218.55 3 764.99 372.07 392.92 98825.63 178 764.99 8.54 756.45 1521.42 179 764.99 5.71 759.29 762.14 180 764.99 2.86 762.14 e.00 Press any key to continue
Instructions
You are working as a computer programmer for a mortgage company that provides loans to consumers for residential housing. Your task is to create an application to be used by the loan officers of the company when presenting loan options to its customers. The application will be a mortgage calculator that determines a monthly payment for loans and produces an amortization schedule for the life of the loan.
The company offers 10-, 15-, and 30-year fixed loans.
Inputs
The program should initially prompt the user (the loan officer) for the principal of the loan (i.e. the amount that is being borrowed).
It should then ask him or her to enter an annual interest rate for the loan.
The final input should be the number of years that the loan will be outstanding. Because the company only offers three different terms (10-, 15-, and 30-year loans), the program should ensure that no other terms are entered.
Payment Calculator
The formula to calculate the monthly payment for a fixed interest rate loan is as follows: A=P[(1+r)^n]/[(1+r)^n-1]
Example: What would the monthly payment be on a 15-year, $100,000 loan with a 4.50% annual interest rate?
P = $100,000
r = 4.50% per year / 12 months = 0.375% (or 0.00375) per period
n = 15 years * 12 months = 180 total periods
A = 100,000 * (.00375 * (1 + .00375)180)/((1+.00375)180 – 1)
Using these numbers in the formula above yields a monthly payment of $764.99.
Requirements:
- Start your program by prompting the user to enter a principal amount. The data type of this number should be a double. The amount must be positive and it must also be a numeric value.
- Prompt the user to enter an annual interest rate for the loan as a percent. For example, an annual interest rate of 4.5% should be entered as 4.5. Your program will convert it to .045 for calculations.If a non-numeric or negative interest rate is entered, prompt the user to re-enter the rate.
- Prompt the user to enter the term of the loan. Valid terms are 10, 15, and 30 years. Any other entries should be rejected, and the user should be prompted to re-enter an appropriate value.
- Once the inputs have been entered and validated, your program must calculate the monthly payment for the loan. you must create a function called CalcPayment that receives the principal, interest rate, and number of years as parameters. The function should return the monthly payment that is calculated.
- In main(), using the monthly payment that you just calculated, call a function to create an amortization schedule for the loan using these specifications:
-
- Create a function called Amortize. It should receive as parameters: currentPeriod, totalPeriods, paymentAmount, monthlyInterestRate, currentBalance.
- The function MUST be recursive to receive credit for producing the Amortization Schedule.
- The function should print out the Amortization Schedule to the screen using good formatting (including spelling and grammar where appropriate)
Your program should check for invalid data such as non-numeric and non-positive entries for principal, interest rate, and term.
General notes about error checking
As in all applications, you should design your code to be robust enough to handle anything that a user may enter. In this program, you will prompt the user to enter three numbers: a principal amount, an interest rate, and a number of years (i.e. term). Because users can make mistakes, you need to make sure that they enter numbers for these inputs (as opposed letters or other characters) and that any numbers entered are reasonable.
Therefore, you may use the following code to determine if a non-numeric or negative number has been entered:
int num;
cout << "Enter an integer: " << endl;
cin >> num;
while (cin.fail() || num < 0)
cout << "You must enter a number, and that number must be positive. Please try again. " << endl;
cin.clear();
cin.ignore(numeric_limits<streamsize>::max(), '\n');
cin >> num;
}
the output is the image
Trending now
This is a popular solution!
Step by step
Solved in 8 steps with 5 images