Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

CSE 231

Spring 23

Computer Project #3

Assignment Overview

This assignment focuses on the design, implementation and testing of a Python program to calculate values related to the purchase of a home using a traditional mortgage loan system (see below).

It is worth 20 points (4% of course grade) and must be completed no later than 11:59 PM on Monday, January 30, 2023. After the due date, your score will be deducted by 1pt for every 2 hours late.

Assignment Deliverable

The deliverable for this assignment is the following file:

proj03.py – the source code for your Python program

Be sure to use the specified file name and to submit it for grading via the Coding Rooms system before the project deadline.

Assignment Background

When prospective home buyers which to purchase a new home, they can take out a loan from a bank to allow them to buy the home without having the full purchase price. This is called a mortgage. The mortgage loan is paid back to the bank over time with interest. When looking at  available homes, it is helpful to understand how various factors impact the mortgage. A buyer    must be aware of the principal loan amount, the down payment, the annual percentage rate (APR) of the loan, the length of the loan, the property taxes, the cost of living within a given area, the cost of homeowner’s insurance, and realtor costs. We will ignore a few of these factors to simplify the problem space.

For this assignment, you will design a program that asks the users to provide some of the following details: the desired location of the house, the desired size of the house in square feet, the desired maximum monthly payment, the expected down payment, and the current APR. Using this information, the program will compute and output either the estimated monthly payment or the maximum square footage that the buyer should consider given the values provided.

Assignment Specifications

1.  You will develop a Python program which calculates details for a mortgage loan for one or more houses based on the input variables described in detail below.

2.  The program will first print a simple welcome message (use the provided strings), and then    repeatedly ask if the user wishes to process another mortgage.  If the user’s response is the letter Y or the letter y, the program will proceed with the steps to calculate the values associated with a new set of inputs for a mortgage loan. If the user’s response is anything else, the program will     quit.

3.  When the user chooses to process a mortgage loan, the program will prompt the user to enter the desired location of the house, the desired square footage of the house, the user’s maximum  monthly payment, the user’s expected down payment, and the current APR. You should use the prompts provided for each of these inputs in the file strings.txt” . Users will be advised to enter as much information as possible or “NA” if they don’t have a value to input. The program will  behave in response to which values are present and which are missing.

4.  For each of the inputs, handle the input as follows.

For location, the user must provide one of the following cities: Seattle, San Francisco, Austin,   East Lansing. The starter file contains the corresponding property tax rates and real estate prices per square foot for each of these locations. If the user types any other value, use the average       national values for those two metrics and display the unknown location message.

For square footage, you may assume the user has typed a positive value or NA” . If the value is numerical, convert it to a float; otherwise, you will compute a maximum square footage given  the values of the other variables (presuming those values are valid). The square footage will be multiplied by the price per square foot based on the location selected.

For maximum monthly payment, you may assume the user has typed a positive value or NA” . If the value is numerical, convert it to a float; otherwise, you will compute the details of the             mortgage loan given the values of the other variables (presuming those values are valid).

For down payment, you may assume the user has typed a positive value or NA” . If the value is numerical, convert it to a float; otherwise, you should assign the variable a value of 0. You will deduct the down payment from the total cost of the house to get the amount of the mortgage      loan.

For APR, you may assume the user has typed a positive value between 0 and 100 or NA” . If it is numerical, convert it to a float and store it for use in your calculations (i.e., not as you would display it, nor as the user typed it); otherwise, assign the value stored in the APR_2023 constant that has been provided.

Note: if neither desired square footage nor maximum monthly payment have been provided, display the message for not enough information.

5.  If the user has provided a square footage, you should estimate the home cost for the given  location based on the corresponding values. You will also need to calculate the principal value based on the estimated home cost and the down payment. Mortgage loan information will be displayed containing all the provided information as well as the monthly taxes and the monthly payment. The message should be displayed like the one shown below.

In Austin, an average 1000 sq. foot house would cost $349000.

A 30-year fixed rate mortgage with a down payment of $50000 at 4.0% APR results

in an expected monthly payment of $526.41 (taxes) + $1427.47 (mortgage payment) = $1953.88

If the user has provided a maximum monthly payment in addition to the square footage, print a message telling the user whether they can or cannot purchase the home described given their maximum monthly payment amount. An example is shown below.

Based on your maximum monthly payment of $2200.00 you can afford this house.

Finally, ask the user if they wish to see the amortization table for the mortgage loan. An amortization table shows how the monthly payment will be allocated each month. Some of the    payment is directed to pay off the interest owed on the loan, and the rest goes to reduce the overall balance of the loan. The amount of interest is based on the current balance remaining and the monthly interest rate. Use proper formatting for the amortization table with a header and well-spaced values for month number, interest payment, principal payment, and remaining balance (see examples).

6.  If the user has not provided the square footage but has provided the maximum monthly payment, calculate the maximum square footage that their monthly payment can afford in the location specified. Report this as shown below. Hint: use the formula below and solve for the principal first.

In East Lansing, a maximum monthly payment of $2000.00 allows the purchase of a house of 2062 sq . feet for $350582 assuming a 30-year fixed rate mortgage with a $40000 down payment at 6 .7% APR .

Assignment Notes

1.  The coding standard for CSE 231 is posted on the course website:

http://www.cse.msu.edu/~cse231/General/coding.standard.html

Items 1-7 of the Coding Standard will be enforced for this project.

2.  The important information related to the calculation of the mortgage loan appears below. The formula for calculating the monthly payment owed (before considering taxes or other associated costs) is:

M = P ( I ( 1 + I )^N ) / ( ( 1 + I )^N – 1 )

Where M = the monthly payment; P = the principal amount or current loan balance; I = the     interest rate (note the APR is annual and you need a monthly rate for this calculation); N = the number of payments in the loan term.

The formula for calculating the cost of a home from the desired square footage and price per square foot for a given location is:

cost = square footage * price per square foot

The formula for determining the amount of the mortgage loan is:

loan amount = cost down payment

The formula for calculating the monthly property taxes due is:

monthly taxes = home price * property tax rate / 12

When creating the amortization table, you will need to multiply the remaining loan amount by    the monthly contribution to the annual percentage rate. Once you have determined the amount of your payment that is used to pay of the loan interest, you can then calculate the amount of your   payment that should be deducted from the remaining loan amount.

payment to interest = remaining loan amount * APR / 12

payment to loan = payment payment to interest

remaining loan amount = remaining loan amount payment to loan

3.  The program will produce reasonable and readable output, with appropriate labels for all       values displayed. Dollar amounts should be rounded to two decimal places, and percentages      should be shown as a user expects (ex. the APR may be 3.5%, which in your program should be stored as 0.035).

4.  When asked to format tabular data, you should consider using the string formatting descriptors. These can be found on p. 211-214 of the text. There are four columns, and these should be formatted as shown below.

Month:

Interest:

Principal:

Balance:

field width 7, centered

field width 9, two decimals, right-aligned

field width 10, two decimals, right-aligned

field width 11, two decimals, right-aligned

Between each of the fields there should be a single vertical bar printed. Before each of the monetary calculations there should be a single space followed by a dollar sign. After each monetary calculation there should be a single space (before the vertical bar).

Suggested Procedure

Solve the problem using pencil and paperfirst. You cannot write a program until you have figured out how to solve the problem.  This first step can be done collaboratively with another student.  However, once the discussion turns to Python specifics and the subsequent writing of Python statements, you must work on your own.

•   Cycle through the following steps to incrementally develop your program:

o Edit your program to add new capabilities.

o Run the program and fix any errors.

o Use the Coding Rooms system to submit the current version of your program.

•   Be sure to use the Coding Rooms system to submit the final version ofyour program.

•   Be sure to log out when you leave the room, if you’re working in a public lab.

The last version of your solution is the program which will be graded by your TA.

You should use the Coding Rooms system to back up your partial solutions, especially if you are working close to the project deadline. That is the easiest way to ensure that you won’t lose significant portions of your work if your machinefails or there are other last-minute problems.

You would also be wise to save a copy of your completed program in your local computer before the project deadline.

In case of problems with electronic submission, an archived copy in the Coding Rooms system is the only acceptable evidence of completion.

Hints

1.   Your program should branch based on which inputs it receives. Identify the possible     cases (which inputs it has available to use), and then define the behavior based on those outcomes.

2.   To resolve some of the cases with missing data, you will need to rearrange the            mathematical formulas provided. This is a good pencil and paper task that you should perform before writing the code. Then make sure to test your results to make sure that you have translated the rearranged formula to Python Code correctly.

3.   Later in the course, we will show you different ways to test input from the user. For this assignment, make sure to consider the type before trying to convert what the user has    entered into a numerical type.

4.   When designing the amortization table, consider which values should change on each   iteration of a loop and design your code to update them in a clear way. Loops that don’t update variables related to their test condition are often the source of issues down the    line.

Grading Rubric

Computer Project #03

General Requirements:

( 3 pts) Coding Standard 1-7

Scoring Summary

(descriptive comments, mnemonic identifiers, format, etc...)

Implementation:

(2 pts) Test Case 1:

(3 pts) Test Case 2:

(4 pts) Test Case 3:

(3 pts) Test Case 4:

(5 pts) Test Case 5:

Sample Output

Test 1

MORTGAGE PLANNING CALCULATOR

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

Enter a value for each of the following items or type 'NA' if unknown

Where is the house you are considering (Seattle, San Francisco, Austin, East Lansing)? East Lansing What is the maximum square footage you are considering? NA

What is the maximum monthly payment you can afford? 2000

How much money can you put down as a down payment? 40000

What is the current annual percentage rate? NA

In East Lansing, a maximum monthly payment of $2000.00 allows the purchase of a house of 2062 sq . feet for $350582 assuming a 30-year fixed rate mortgage with a $40000 down payment at 6 .7% APR .

Would you like to make another attempt (Y or N)? N

Test 2

MORTGAGE PLANNING CALCULATOR

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

Enter a value for each of the following items or type 'NA' if unknown

Where is the house you are considering (Seattle, San Francisco, Austin, East Lansing)? Seattle What is the maximum square footage you are considering? 850

What is the maximum monthly payment you can afford? 2200

How much money can you put down as a down payment? 50000

What is the current annual percentage rate? 4.25

In Seattle, an average 850 sq. foot house would cost $424150.

A 30-year fixed rate mortgage with a down payment of $50000 at 4.2% APR results

in an expected monthly payment of $325.18 (taxes) + $1840.59 (mortgage payment) = $2165.77 Based on your maximum monthly payment of $2200.00 you can afford this house.

Would you like to print the monthly payment schedule (Y or N)? N

Would you like to make another attempt (Y or N)? N

Test 3

MORTGAGE PLANNING CALCULATOR

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

Enter a value for each of the following items or type 'NA' if unknown

Where is the house you are considering (Seattle, San Francisco, Austin, East Lansing)? Austin What is the maximum square footage you are considering? 900

What is the maximum monthly payment you can afford? 2100

How much money can you put down as a down payment? 40000

What is the current annual percentage rate? 6

In Austin, an average 900 sq. foot house would cost $314100.

A 30-year fixed rate mortgage with a down payment of $40000 at 6.0% APR results

in an expected monthly payment of $473.77 (taxes) + $1643.37 (mortgage payment) = $2117.14 Based on your maximum monthly payment of $2100.00 you cannot afford this house.

Would you like to print the monthly payment schedule (Y or N)? Y


Month |  Interest  |  Principal  |   Balance

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

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

|

$

$

$

$

$

$

$

$

$

$

$

$

$

$

$

$

$

$

$

$

$

$

$

$

$

$

$

$

$

$

$

$

$

$

$

$

$

$

$

$

$

$