• Make Order

  • order processing

  • Approve and Get
    your Order
Order Now

loan calculater

Loan Calculator
You’ve been hired to do some programming for Metro Bank. They want you to create a program to calculate loan payments. The user will enter the amount of money to borrow from the bank, the annual percentage rate (that will be compounded monthly) and the number of years to pay back the loan. The program will then display the monthly payment and the total amount of interest that will be paid. Also, to be more helpful to the user, display these same results using a loan amount of 10% more and 10% less.
Objectives
writing your own functions with parameters and return values
gaining more experience working with calculations
User Interface
INPUT
After displaying a user introduction, the program asks for:
the amount of loan in dollars,
the length of loan (in years), and
the annual percentage rate.
For the percentage rate, the user enters a percentage value. For example, if the percentage rate is 5%, the user should enter 5, not the decimal 0.05. Programs should not make the user do the math.
Make sure that the prompt clearly tells the user what to input and the units for each input. 

OUTPUT
The program must first redisplay the original input. Then,
display the monthly payment and the total interest (see formulas below).
display monthly payment and total interest using a loan amount of +10% and -10% to give the user a range of results.
All dollar amounts must be displayed with exactly 2 decimal spaces. All displayed values need to be properly labeled.
Formulas and Code Specifications
Periodic Payment
Let:
A = amount of the loan
r = interest rate per month as a decimal, not percentage
n = the number of months

Then the formula to find the monthly payment is:
payment.gif

Total Interest Paid
Let:
P = the monthly payment
n = the number of months
A = amount of the loan

Then the formula to find the total interest is:

Total Interest = nP – A

Functions:
For this program, you will write a function to calculte each of the formulas above. Remember that once you have written a function you need to call it to get it to execute.
Write a function defintion that is passed in the amount of the loan, the number of periods, and the interest rate per period (as a decimal) and returns the monthly payment.

Notice that the units of the parameters are the same as the units in the formula. However, these are different from the units input by the user. So you’re program will need to do some unit conversions before calling the function.

Write a function definition that is passed in the monthly payment, the number of periods, and the amount of the original loan and returns the total interest paid. Again, be mindful of units.

Also, be aware that since you are formatting the monthly payment to 2 decimal places, that must also be the value used to calculate total interest. Otherwise, you’ll have a rounding error.

Since the program needs to output 3 sets of results (results for the user input loan, as well as + 10% of loan amount and -10% of loan amount)  put the code to display the output nicely into one function and call it for each set of data.
This means your program will have a minimum of 4 function definitions:  main(), the 2 calculation functions, and a display function.
How to Get Started
The first step I recommend is to implement the periodic payment function and test it, similar to lab 3. Reread the description, identify the parameters and the return, then work on the calculation. Once you have written the function, test it by calling the function and displaying the results. Perform some calculations by hand to confirm that the function works properly.

Next, implement and test the other calculation function.
Here are some test data to use for testing your functions. Remember to make sure you are using the correct units. For example, a loan length of 3 years does not mean to pass in a 3 to the periodic payment function. How many monthly payments are there in 3 years? That’s the number to pass in. You’ll have to do a similar conversion on the interest rate: annual percentage rate is not the same as periodic decimal rate.

loan amount = $5000
loan length in years = 3
annual rate = 12%

monthly payment = $166.07
total interest = $978.52 
loan amount = $1500
loan length in years = .25 (3 month loan)
annual rate = 12%

monthly payment = $ 510.03
total interest = $ 30.09
Once you have gotten these functions to work, then focus on the main() function to complete the user input and the final display.

Documentation & Style Specifications
Refer to the Comment Descriptions and Documentation Standards page in Canvas.
Include header comments at the top of the file listing that has your name, date, and a description of the program (remember, this is different than a user introduction). The description should be 2  or more lines long describing what the program does.
Include block comments for each function definition, except main(), to describe what it does.  These block comments go directly above the function defintion.
make sure to describe parameters and return values. Follow the style you see in the posted examples.
Include blank lines to separate function defintions and blocks of code.
Use descriptive variable names.
Use named global constants for the increase/decrease in loan value.
Use comments elsewhere that you think would help guide the reader. You don’t want to overdo it though. Not every line of code needs a comment. Think in terms of blocks, or if a calculation is not clear.
Assume the reader has not read the homework assignment.
Assume the reader knows Python.

You can leave a response, or trackback from your own site.
Powered by WordPress | Designed by: Premium WordPress Themes | Thanks to Themes Gallery, Bromoney and Wordpress Themes