Question
in c++ please, it needs to use the same function to calcuate and compare TWO seperate loans We want a program which will compare the
in c++ please, it needs to use the same function to calcuate and compare TWO seperate loans
We want a program which will compare the two loans. The program will get the following information about the first loan:
The amount to be borrowed (for example 1000.00)
The annual interest rate (for example 12 for twelve percent per year)
The amount to be paid per month
For each loan, the program will start by asking how much will be borrowed and storing the reply as this amount. Next, the program will ask what the annual interest rate will be and it will store this amount divide A function will be used to get a valid amount for the monthly payment. The amount returned will be a double which has been checked by the function to ensure that it is not too small to eventually pay off the loan. The function will be passed the amount borrowed and the yearly interest percentage. The annual rate is divided by 12 to get the monthly rate. For example, 12 percent per year will be .01 per month. The function will find out the amount of interest paid for the first month by multiplying the amount borrowed by the monthly interest rate. When the user enters the amount to be paid per month, there will be a loop which compares the amount of interest for the first month with the monthly payment. If the monthly payment is not more than the interest for the first month, a message is displayed and the user is asked to enter a larger monthly amount. (Otherwise, the loan could never be paid off.)
The program will call another function which will calculate the total amount paid on the loan and return that value. This function will be passed the amount borrowed, the monthly payment amount, and the annual interest rate. It returns the total amount paid as a double.
Next, the program will get the same information for the second loan and use the same functions to calculate the total amount paid on the second loan. Note that different sets of arguments are passed to the functions for the new calls.
Finally, the following information is displayed:
The difference in the amount borrowed (i.e. the amount of the first loan minus the amount borrowed for the second loan).
The difference in the interest rates.
The difference in the amount paid per month
The total amount paid for the first loan.
The total amount paid for the second loan.
The difference in the total amount paid for the loans.
The function which calculates the total amount paid for a loan works as follows. It sets up its local variables. Then it begins a loop to calculate how much money it will take. The total paid variable will keep track of the sum of the monthly payments. The loop will keep cycling until the amount of the loan is reduced to zero. Each month (each cycle) the amount of the loan is increased by the amount of the interest charge (this interest charge changes each month). The amount of the loan is reduced by the monthly payment or the amount owed, which ever is lower. The total paid is increased by the amount paid this month. Note that the last payment will probably be only the amount remaining to be paid, not the usual monthly amount. When the amount of the loan is reduced to 0, the function returns the total amount paid.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started