Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please You must use Python . Objective: To calculate how long it will take to pay off a loan. Your program will ask the user

Please You must use Python.

Objective: To calculate how long it will take to pay off a loan.

Your program will ask the user to enter the amount of money they want to borrow, the interest rate, and the monthly payment amount. Your program will then determine how many months it will take to pay off that loan, what the final payment amount will be, and how much interest was paid over that time. If the monthly payment amount isn't high enough to pay off more than one month's interest, your program should notify the user what the minimum monthly payment is.

Here are some examples of how your program should behave. Please use the exact same test cases as these, so that we can verify that your program works:

 ** Welcome to the Consumer Loan Calculator **
 How much do you want to borrow? $1000 
What is the annual interest rate expressed as a percent? 18 
What is the monthly payment amount? $50 
Your debt will be paid off after 24 months, with a final payment of just $47.83 
The total amount of interest you will pay during that time is $197.83 
**Don't get overwhelmed with debt! ** 
 
 ** Welcome to the Consumer Loan Calculator **
 How much do you want to borrow? $15000 
What is the annual interest rate expressed as a percent? 10 
What is the monthly payment amount? $100 
You must make payments of at least $126.00 Because your monthly interest is $125.00
 ** Don't get overwhelmed with debt! ** 
 
 ** Welcome to the Consumer Loan Calculator ** 
How much do you want to borrow? $-50 
You must enter a positive number!
 How much do you want to borrow? $-200 
You must enter a positive number! 
How much do you want to borrow? $20000
 What is the annual interest rate expressed as a percent? -2.5 
You must enter a positive number! What is the annual interest rate expressed as a percent? 5 
What is the monthly payment amount? $0 
You must enter a positive number! What is the monthly payment amount? $200 
Your debt will be paid off after 130 months, with a final payment of just $125.79 
The total amount of interest you will pay during that time is $5925.79 
** Don't get overwhelmed with debt! ** 

Here are the rules and some tips:

  • Your program must notify the user if their monthly payment isn't high enough, and tell them what the minimum payment is to pay off one month's interest (and thus make progress paying off the debt).
  • Your program should have at least 3 functions, including a main() function (no global variables or global code other than a call to main within an if-statement)
  • Every function (except main) needs to have a comment in a triple-quoted string at the beginning, briefly explaining what it does.
  • The user enters the interest rate as an annual percentage rate. You need to convert this annual percentage to a monthly decimal. For example, 12% annual interest is 1% per month, which is 0.01
  • Your program must allow only positive numbers to be entered by the user, as shown above
  • This program should mimic the standard way loans work for credit cards, car loans, and home mortgages: Each month the following happens:
    • The balance (amount owed) is multiplied times the monthly interest rate to determine how much interest is owed this month. This amount of interest is added to the principle (additional debt)
    • This amount of interest is also added to the total interest so far (to be output at end)
    • The monthly payment is subtracted from the balance, reducing the amount of debt.
    • The month is counted (to be output at end)
    This is repeated each month until the debt is paid off (balance reaches zero). The best way to understand it is to look at an example. Let's say you borrow $100. That's also called the balance or principle. Imagine your interest rate is 12%. That's an annual (yearly) rate, so it's 1% per month, so you multiply the balance times 0.01 to get the amount of interest. If your monthly payment is $50/month, then here's what happens:

    Month 1:

    $100 * 0.01 = $1 interest for the month adding interest and subtracting the payment: $100 + $1 - $50 = $51 new balance

    Month 2:

    $51 * 0.01 = $0.51 interest for the month adding interest and subtracting the payment: $51 + $0.51 - $50 = $1.51 new balance

    Month 3:

    $1.51 * 0.01 = $0.02 interest for the month (you don't have to round in your calculations) adding interest and subtracting the payment: $1.51 + $0.02 - $50 = -$48.47 new balance

    Since the new balance is negative, the loan is paid off, and the final payment is too much. It should have been $50 - $48.47 = $1.53 final payment.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essential Data Protection For Estate Agencies In Singapore 2024

Authors: Yang Yen Thaw Yt

1st Edition

B0CQK79WD3, 979-8872095392

More Books

Students also viewed these Databases questions

Question

2. Identify conflict triggers in yourself and others

Answered: 1 week ago