Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON Write a mortgage code The amount borrowed, called the principal (P) , is paid off in monthly payments over a stated number of years

PYTHON Write a mortgage code

The amount borrowed, called the principal (P) , is paid off in monthly payments over a stated number of years called the term (usually 25 or 30 years). The amount of the monthly payment depends on the principal, the interest rate, and the term of the mortgage. If P dollars are borrowed at r% interest compounded monthly to purchase a house with monthly payments for n years, then the monthly payment is given by the formula

Monthly payment = ( i / (1 - (1 + i)^(-12n))) * P

where i = (r / 1200)

Create a class named Mortgage with a constructor that takes three parameters and initialize the instance variables for principal, interest rate, and term with the parameters. Create a method named calculateMonthlyPayment that returns the monthly payment based on the formula from above. Create an instance of Mortgage class at the main script section and ask the user for inputs as follow:

Enter principal of mortgage: 350000

Enter percent interest rate: 5.25

Enter duration of mortgage in years: 30

Monthly payment: $1,932.71

(Possible outcome)

Use string format to print the rate and the payment to two decimal places

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