- The objectives of this challenge are very simple.
You are about to create an application
to calculate the monthly loan payments.
Another objective is to integrate multiple concepts in C
that you learned throughout this course
and to write code that has a practical application.
Let's get into the specifics.
You will ask the user to enter the loan amount,
the number of years to pay back,
and the yearly interest rate.
You will then display the monthly payment,
you will calculate it, and the total payback,
so the entire amount that the person
is going to pay back over the years.
To help you with that, I'm going to give you
some guidance and some formulas.
The loan payment is the total amount divided by discount.
This is an accounting formula.
The loan amount, it's obviously
the entered amount by the user.
So, let's say you want to borrow 20,000, 100,000,
whatever the amount is.
The discount will have to be calculated.
To calculate the discount, we need a few other data points.
N would be the number of payments a year.
So this would be 12, typically,
because you have monthly payments every year.
I is the annual rate, divide by 100,
then all of this divide by 12.
So, for example, if you want to say the annual rate is 6%,
the annual rate itself would be six.
You would divide six by a hundred
and then again by 12, and this will give you i.
And then, you plug in all these numbers into a formula,
and you calculate the discount.
So, just to clarify what you see there,
it's 1+i in parenthesis to the power of n,
then all of that minus one,
and this gets you the curly brackets.
You divide that by the quantity in the square brackets,
which is i times 1+i to the power of n.
There you get your discount.
You plug it back in the formula in the second bullet,
which is the amount divide by discount,
and this will be your monthly payment on any type of loan.