Mortgage Payments
You're comparing different $100,000 Mortgage plans for your house and would like to know how much interest you will pay in total for each one. To keep things simple, you will pay off the same amount of the principle loan annually, and pay a fixed interest rate on the remaining loan. For each plan, you will be given the fixed interest rate and the number of years of the mortgage. Can you print the total interest you will pay?
For example, given a 5% interest rate and a 10-year mortgage, you will pay $5,000 in interest the first year and $10,000 to pay off the principle every year. Below is the interest you will pay each year:
year | amount remaining (before payment) |
interest |
---|---|---|
1 | 10k | 5000 |
2 | 9k | 4500 |
3 | 8k | 4000 |
4 | 7k | 3500 |
5 | 6k | 3000 |
6 | 5k | 2500 |
7 | 4k | 2000 |
8 | 3k | 1500 |
9 | 2k | 1000 |
10 | 1k | 500 |
In total, you will pay 27500
dollars of interest, which is what you should print.
Challenge
You will be given the interest rate and years of a mortgage as doubles. Print out the total interest you will pay over the term of a $100k mortgage, as an integer.
Please sign in or sign up to submit answers.
Alternatively, you can try out Learneroo before signing up.
Comments
thales
Jul 20, 6:42 AMa solution:
my code