Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Please modify the python 3 code below. Please make sure the code works below. 2. Please show all outputs and share code updates. 3.

1. Please modify the python 3 code below. Please make sure the code works below.

2. Please show all outputs and share code updates.

3. Write ans share the code for parts 2(b) and 2(c) for the code given below.

New Question based on code given below:

Problem 2(b). Testing.

When writing complicated code, it is always a good idea to test your code on simple examples.

Use the following test cases to make sure your code matches calculations you can perform by hand. (Of course, if it does not match, please fix your code.) For each test case, print the results.

For each, use $500$500 for the principal, and an annual interest rate of 5%5%.

Monthly Payment: $100$100

Monthly Payment: $500$500

Monthly Payment: $1$1

 

New Question given on code below:.

Problem 2(c). Calculator Analysis.

Answer the following questions in a markdown cell.

Describe in your own words how the mortgage calculator works. What are the steps you are computing? What are you keeping track of in each iteration?

Suppose you had a mortgage with a principal of $250,000$250,000, an interest rate of 4%4%, and a monthly payment of $1000$1000.

How long would it take you to pay it off?

How much would you have paid in total?

Using a code cell, print the amortization schedule.

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Original Instrucation and Given Code Part 2(a) Please verify code works per instructions given above.

Mortgage Calculator.

Buying a house is one of the biggest financial transactions that many people ever undertake. Even a small difference in interest rates or monthly payments can make a large difference in how much you ultimately pay for your mortgage. However, these details are often buried in masses of paperwork--so it pays to be able to calculate the long-term cost of a mortgage yourself.

In a mortgage, the bank lends you a certain amount of principal to purchase a house at a certain interest rate. Every month, the amount you owe (the balance) first increases due to interest: 1/12 of the interest rate times the current balance. Then the balance decreases due to your monthly payment.

For example, suppose you borrow $100,000$100,000 at 5%5% annual interest, with $500$500 monthly payments. In the first month, the interest increases the balance by $416.67$416.67, and then your payment reduces it by $500$500, for a remaining balance of $99,916.67$99,916.67. In the second month, the interest charge is $416.32$416.32, and the remaining balance is $99,832.99$99,832.99.

If you continue this process, you get an amortization table like this:

month payment interest balance 1 500 416.67 99916.67 2 500 416.32 99832.99 3 500 415.97 99748.96 4 500 415.62 99664.58 5 500 415.27 99579.85 6 500 414.92 99494.76 7 500 414.56 99409.32 8 500 414.21 99323.53 9 500 413.85 99237.38 10 500 413.49 99150.87 

You can also compute the total amount of time and money to pay off the mortgage. In this example, it takes 35 years and 11 months, and the total amount paid is approximately $215,458.84$215,458.84.

Create a mortgage calculator that takes as input the principal loan amount, interest rate, and monthly payment. As output, your calculator should generate an amortization table, and compute how many years and months it took to pay off the mortgage, and report the total amount of payments over that time.

Things to consider when implementing the calculator

For dollar values, only display two digits of precision after the decimal point.

You can assume that the bank will not round internally!

You must not round internally either!)

The final payment will almost certainly be smaller than the others, so be careful to check for that case so you don't end up with a negative balance. The final balance must be 0.

If the monthly payment is too small, the balance will go up every month!

If this happens, the program should stop and display an appropriate error message.

Manually stopping your code in this case is not considered a solution -- your submitted code must detect the problem itself, and not enter an infinite loop.

If you accidentally create an infinite loop during development and testing, interrupt or restart the kernel. See the Kernel menu up top.

Use the modulus or %% operator to separate the years and months.

Your program should only display the columns requested, and the rows should be formatted to appear under the appropriate heading.

 

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

Database Management With Website Development Applications

Authors: Greg Riccardi

1st Edition

0201743876, 978-0201743876

More Books

Students also viewed these Databases questions