programming using python

profilepwillie
CS151PA2Summer2018HowmuchdoesitREALLYcost11.pdf

Programming Assignment #2 Summer 2018

CS151: Computer Science through Programming Summer 2018

Programming Assignment #2: How much will it REALLY cost?

PROBLEM: When making a purchase of an item, the actual cost of the item is usually straight-forward… an item is priced, you pay the price, end of story. However, when purchasing an item which is priced higher than you can immediately afford, a discussion related to “how are we going to afford this thing?” must take place. The answer?? Re-think the item you’re planning to purchase, or get a loan to help to finance what you can’t afford immediately! This personalized program will calculate the cost of making a purchase, using a loan, if necessary, to allow the desired item to be purchased.

PURPOSE OF THE ASSIGNMENT The purpose of this assignment is to give you

 reinforcing previous Python logic, particularly, input/output, decision-making, loops, and error-checking

REQUIREMENTS: The first stage in your programming assignment is the requirements analysis stage. You need to make sure you understand the below requirements for what needs to be included in your solution. Your personalized program must evaluate the cost of purchasing an item, taking into account the following quantities: (U = user-provided data; CALC = value that is calculated using a formula and/or use of logic) Input Data Required:

 The user’s first name (U)  Item to purchase? (U) [Home / Other]  allow any case variation of these 2 options  Item Description (U)  Cost of the item in dollars (U)  Down payment in dollars (U)  Duration of loan in years (U)  Fair Isaac Corporation (FICO) score (U)  Number of loan interest rates to process (U)

o Loan interest rates (Annual Percentage Rate (APR) in percent) (U)  Annual Insurance Cost on item (U)

Programming Assignment #2 Summer 2018

Output Required:  Loan amount in dollars (CALC)  PMI (if applicable) by year and by month (see Calculation details) (CALC)  Monthly insurance cost in dollars (CALC)  FINAL loan interest rate (see below for details) (CALC)  Total number of loan payments (CALC)  Monthly loan payment (see Calculation details) (CALC)  Total monthly payment (Loan amount + PMI + Insurance) (CALC)

1. Your solution must ask the user for the user-provided data required for calculations

2. Calculation details:

TOTAL Monthly Payment = Monthly Loan Payment (P) + Monthly PMI Cost (if item is a home) + Monthly Insurance Cost

Loan Payment = the monthly cost of repayment for the loan taken from the lending institution based on the following formula:

P = monthly loan payment in dollars PV = loan amount (Item Cost – Down Payment) in dollars

r = FINAL monthly Loan interest rate (see below for details) n = total number of periods or monthly payments

Notes:  FINAL Loan interest rate

This interest rate depends completely on the user’s financial risk factor, which is tied to their FICO (credit) score, which ranges from 300 (very poor) to 850 (exceptional). For this exercise:  if the user’s FICO score is between 300 and 499, an 8% surcharge

is added to the Loan Interest Rate entered by the user  if the user’s FICO score is between 500 and 699, a 4% surcharge

is added to the Loan Interest Rate entered by the user  if the user’s FICO score is greater than or equal to 700, there is

no surcharge added to the Loan Interest Rate entered by the user

 Private Mortgage Insurance (PMI) (for home purchases only!) When a prospective homeowner makes a down payment of less than 20% of the selling price of the home, most lenders require the borrower to purchase private mortgage insurance to protect the lender from losing money if the borrower ends up foreclosing, or failing to make loan payments.

Programming Assignment #2 Summer 2018

For this exercise:  if the down payment entered by the user is less than 20% of the

original price of the home to be purchased:  the annual cost of PMI is 2.5% of the original loan

amount per year for those with a FICO score of greater than or equal to 600

 the annual cost of PMI is 4.5% of the original loan amount per year for those with a FICO score of less than 600.

See below for sample output…

Sample Calculation #1:

Please enter your name: STUDENT

Item to purchase: Other

Item Description: Ford F-350 and Trailer

Item Cost: $ 50000

Down Payment: $ 5000

Loan Duration (years): 10

FICO Score: 800

Number of loan interest rates to average: 3

Loan Interest Rate #1 (APR %): 3

Loan Interest Rate #2 (APR %): 5

Loan Interest Rate #3 (APR %): 7

Annual Insurance Cost: $ 1200

LOAN Amount: $ 45000

PMI (per Year): $ N/A PMI (per month): $ N/A

Monthly Insurance Cost: $ 100

FINAL Loan Interest Rate (APR): 5%

Total Number of Loan Payments: 120

STUDENT, purchasing your Ford F-350 and Trailer will cost:

Loan Payment (Monthly): $ 477.29

TOTAL Monthly Payment (Loan Payment + PMI + Insurance): $ 577.29

Sample Calculation #2:

Please enter your name: STUDENT

Item to purchase: Home

Item Description: 3-bedroom Ranch

Item Cost: $ 225000

Down Payment: $ 20000

Loan Duration (years): 10

FICO Score: 650

Number of loan interest rates to average: 3

Loan Interest Rate #1 (APR %): 3

Loan Interest Rate #2 (APR %): 5

Loan Interest Rate #3 (APR %): 7

Annual Insurance Cost: $ 1200

LOAN Amount: $ 205000

PMI (per Year): $ 5125 PMI (per month): $ 427.08

Monthly Insurance Cost: $ 100

FINAL Loan Interest Rate (APR): 9%

Total Number of Loan Payments: 120

STUDENT, purchasing your 3-bedroom Ranch will cost:

Loan Payment (Monthly): $ 2596.85

TOTAL Monthly Payment (Loan Payment + PMI + Insurance): $ 3123.94

Programming Assignment #2 Summer 2018

As always, your solution should:  Follow good programming practices.  Follow the process below, including meeting all detailed requirements.  Properly use variables, input/output, math/evaluation, decision making  Complete a set of test cases, and use them to test that your program works correctly. Fix

any errors.  For this exercise, you can assume that if you request that the user enter a numeric value,

they will follow your instructions. In the next Programming Assignment, this inputting of data from the user will become more strict.

DESIGN: The second stage is to design your solution based on the requirements:

 Write out your algorithm, including variables used, input, output, decisions, and calculations.

 Double check that you have included all of the requirements IMPLEMENTATION:

From your APPROVED ALGORITHM, code your solution in PyCharm, saving your Python source code to the Programming Assignments\PA #2 folder on your G: drive under the file name: lastName, CS151, Summer 2018, PA#2.py

DELIVERABLES:

Part A (Due Friday, 6/29/20181): This document should include your program algorithm, including a list of variables you’ll be using when you code your solution, along with a verbal description of how those variables will be used.

Part B (Due Monday, 7/2/20181): To the Programming Assignment #2 File Submission Portal on the class Moodle site

 your Programming Assignment #2 source code file  your Project Report

1 All Lab Activities/Programming Assignments/Quizzes/Exams are due by 11:59pm Eastern on the

specified date, unless otherwise specified.