Question

In: Computer Science

The purpose of this exercise is to give you experience in writing condition-controlled loops. Create a...

The purpose of this exercise is to give you experience in writing condition-controlled loops.

Create a code in Python that will print monthly loan amortization schedule given the loan amount (P), APR i.e. Annual Percentage Rate (r=APR in %/12), loan terms in number of months (n).

Please use these formulas:
Monthly Payment (A) = P * ((r * (1 + r)**n)/(((1+r)**n)-1))
          
Monthly Interest Pmt (mIP)= r * Total Remaining Balance

Monthly Principal Pmt (mPP) = A – mIP

Total Remaining Balance (bal) = bal – mPP

Solutions

Expert Solution

Thanks for the question. Below is the code you will be needing. Let me know if you have any doubts or if you need anything to change. 

Let me know for any help with any other questions.

Thank You!
===========================================================================


def loan_table(loan, apr, month):
    # initialize values
    rper = apr / 1200
    period = 0
    balance = loan
    payment = loan * (rper * (1 + rper) ** month) / (((1 + rper) ** month) - 1)
    # print header
    la = "Loan Amount: $ "
    ap = "APR: "
    months = 'Months'
    payments = 'Payment'
    print(f"{la: <15s}{balance: <11,.2f}")
    print(f"{ap: <15s}{apr: <11.4f}")
    print(f"{months: <15s}{month: <11.2f}")
    print(f"{payments: <15s}{payment: <11.2f}")
    print()
    c1 = "Period (#)"
    c2 = "MonthlyInterest ($)"
    c3 = "Monthly Principal ($)"
    c4 = "New Balance ($)"
    spacer = " "

    print(f"{c1: >11s}{spacer}{c2: >15s}{spacer}{c3: >15s}{spacer}{c4: >15s}")
    # print payment info by period
    while balance > 0:
        period += 1
        mIP = rper * balance
        mPP = payment - mIP
        balance = balance - mPP
        print(f"{period: <11d}{spacer}{mIP: >15.2f}{spacer}{mPP: >15.2f}{spacer}{balance: >20.2f}")


def main():
    loan_amount = float(input('Enter loan amount: $'))
    annual_percentage_rate = float(input('Enter Annual Percentage Rate (%): '))
    months = int(input('Enter the number of months: '))

    loan_table(loan_amount, annual_percentage_rate, months)


main()

====================================================================


Related Solutions

The purpose of this exercise is to practice writing an abstract of an academic work. An...
The purpose of this exercise is to practice writing an abstract of an academic work. An abstract is a concise summary of the topic, goals, content, and argument of an academic work. Learning to write a good abstract is a key step in developing a critique of an academic work—you cannot provide a good critique of an article or book until you are able to first summarize the author’s argument and the evidence she uses to support it. Assignment: For...
Project 3 Details The purpose of this project is to give you experience with creating and...
Project 3 Details The purpose of this project is to give you experience with creating and using custom objects. In it, you will make a couple custom classes that work in tandem with each other, and call them in your main function. For this project we'll be making something kind of like the Chatbot java file we made in class. You will create a Chatbot class that will contain a number of variables and functions. As you can imagine, a...
Do you have experience writing annotations/ an annotated bibliography? If yes, explain. explain the purpose of...
Do you have experience writing annotations/ an annotated bibliography? If yes, explain. explain the purpose of the annotated bibliography assignment? To rephrase the question, how will it inform/assist you in the development of the research paper assignment. From your experience or opinion, what are some of the barriers students face when completing an annotated bibliography assignment? What resources are available to you or do you plan to employ to overcome any barriers you may face when completing this assignment?
CVP Modeling project The purpose of this project is to give you experience creating a profitability...
CVP Modeling project The purpose of this project is to give you experience creating a profitability analysis that can be used to determine the effects of changing business conditions on a client's financial position. Managers often want to know the production level where profits earned from a product cover the cost of resources used to create it. Break-even analysis is how we determine this level. The point at which total sales revenues covers the costs of committed resources is called...
Purpose This project is meant to give you experience with sorting, binary searching, and Big-Oh complexity....
Purpose This project is meant to give you experience with sorting, binary searching, and Big-Oh complexity. Objective "Write in Java please" Your goal is to take a book, as a large text file, and build a digital “concordance”. A concordance is like an index for a book in that it contains entries for words in the book, but it also includes passages from the book containing that word. For example, a query for the word Dormouse in Alice in Wonderland...
Can you create a player vs computer Hangman game on MATLAB using nested loops, for loops,...
Can you create a player vs computer Hangman game on MATLAB using nested loops, for loops, if loops, while loops, arrays and conditional execution, as well as creating an image of the game board. The list below must be considered in the code. - Selecting a word from a dictionary (a text file) - Reading a single letter from the user - Building a character array showing the letters matched so far - Keeping count of the number of guessed...
Purpose: This lab will give you experience modifying an existing ADT. Lab Main Task 1: Modify...
Purpose: This lab will give you experience modifying an existing ADT. Lab Main Task 1: Modify the ListInterface Java interface source code given below. Change the name of ListInterface to ComparableListInterface, and have ComparableListInterface inherit from the built-in Java interface Comparable. Note that Comparable has a method compareTo(). compareTo() must be used in programming logic you will write in a method called isInAscendingOrder() (more about isInAscendingOrder() is mentioned further down in the lab description). You can find a brief summary...
Human Genetics - What will your children be? The purpose of this exercise is to give...
Human Genetics - What will your children be? The purpose of this exercise is to give you some practice working with the major concepts of genetics using specific example of inherited traits present in humans. During this lab, we will observe patterns of inheritance for three general types of traits: autosomal traits controlled by two alleles (hair color, Rh factor, PTC tasting), an autosomal trait controlled by multiple alleles (blood type), and a sex-linked trait (color-blindness). Before we begin this...
Length: 2- 3 page double-spaced Purpose: gaining some experience in writing skills and expand your knowledge...
Length: 2- 3 page double-spaced Purpose: gaining some experience in writing skills and expand your knowledge in EHR. Background: Why do EHR Projects fail? Support your answer with an example of failed EHR project and explain the reasons for their failure. (Explain conceptually in Essay style and do not use bullet points). Please Be cautioned for - Copyrights issues.
In this exercise we will practice using nested loops. You will write s program that prompts...
In this exercise we will practice using nested loops. You will write s program that prompts the user to enter an integer between 1 and 9 and displays a pyramid of numbers, as shown in the example below. The program must validate the input given by the user and make sure that: if the user enters a non-integer the program issues an error message and requests the user provides a valid input. if the user does not enter a number...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT