Question
Python Suppose you buy a car and you are making monthly payments. Two years later, you discover you need to trade it in for a
Python
Suppose you buy a car and you are making monthly payments. Two years later, you discover you need to trade it in for a minivan. How much do you still owe on your car?
The answer to a question like this is found by creating something called an "amortization table" for the loan. This is just a table that shows for each payment, how much went to pay interest, how much went towards paying off what you owe, called the principal, and how much you still owe, called the balance.
Let's start with a small concrete example. Suppose you borrow $100 at an interest rate of 10% per month, and you make monthly payments of $30. A month goes by, and you make your first payment. After that, how much do you owe?
Look at the table below to see how the monthly payments apply to the loan:
Loan Amount: $ 100.00 APR: 10.00% Payment: 30.00 Month (#) Interest ($) Principle ($) Balance ($) 1 0.83 29.17 70.83 2 0.59 29.41 41.42 3 0.35 29.65 11.77 Final Payment 0.10 11.77 0
Write a script that takes a loan amount, an annual percentage rate (APR) and monthly payment and prints a loan table.
# Sample input/output Enter loan amount: 100 Enter annual rate (%): 10 Enter monthly payment: 30 Loan Amount: $ 100.00 APR: 10.00% Payment: 30.00 Month (#) Interest ($) Principle ($) Balance ($) 1 0.83 29.17 70.83 2 0.59 29.41 41.42 3 0.35 29.65 11.77 Final Payment 0.10 11.77 0
Here are a few hints on performing the calculations:
Look at the table to find the calculations we did over and over again:
- What is the repeated action?
calculate the interest # interest = balance * monthly_rate calculate the principal calculate the new balance print one line of the table
- How do we start out?
Initially the balance is the original borrowed amount. Compute the monthly rate. The statements from the first step represent the statements to repeat.
- How do we know whether to keep doing it?Your program should print the table very close to what you see in the sample
- Looking at the sample above, we knew it was the end when the final payment of $11.87 (Principle of $11.77 plus Interest of $0.10) which was less than the monthly payment.
- Tables need to be formatted as shown
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