Mortgage Calculator What Can I Afford

Document Sample

```					Project 2 – On-Line Mortgage Calculator
In this project you will write a client/server application that implements a mortgage calculator. The mortgage
calculator should be designed to handle the three scenarios described below. The formulas you will need as
well as a sample calculation are also provided on the following pages.

Scenarios Handled by the Mortgage Calculator
Scenario 1: Determine Monthly Payments for a Loan
In this scenario the user provides the following information
1. Loan amount
2. Annual interest rate
3. Number of years in which to pay off the loan
4. Number of payments that will be made in each year

The calculator should then display the following information:
1. Amount of each payment
2. Total interest paid over the life of the loan
3. Total amount of money paid for the loan

Scenario 2: Determine the Number of Years Required to Pay Off a Loan
In this scenario, the user provides the following information:
1. Loan amount
2. Annual interest rate
3. Amount of each payment
4. Number of payments that will be made each year

The calculator should then display the following information:
1. Number of years required to pay off the loan
2. Total interest paid over the life of the loan
3. Total amount of money paid for the loan

Scenario 3: Determine a Loan Amount
In this scenario, the user provides the following information:
1. Annual interest rate
2. Amount of each payment
3. Number of payments that will be made each year
4. Number of years in which the loan will be paid off

The calculator should then display the following information:
1. Amount of a loan that these payments will cover
2. Total interest paid over the life of the loan
3. Total amount of money paid for the loan
Requirements
1.   Stand-Alone Mortgage Calculator
a. Write a class called MortgageCalculator that handles the three required scenarios. You will need
to write additional wrapper classes in order the return the results for each scenario.

b.   Write a class with a main method that provides a user interface for the mortgage calculator. This
can be a simple text-base interface. A sample execution might look something like this:

Welcome to the mortgage Calculator
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

What do     you want to do?
1.     Calculate Monthly Payments
2.     Calculate Years To Pay Off A Loan
3.     Determine A Loan Amount

Selection: 2

Selection 2 - Calculate Years To Pay Off A Loan
Enter Loan Amount: 135000
Enter Annual Interest Rate: 6
Enter Amount Of Each Payment: 804
Enter Number Of Payments Per Year: 12

Results:
Number Of Years Required To Pay Loan: 30.57
Total Interest Paid: \$ 706,395
Total Amount Paid: \$ 841,395

c.   Note: This part of project 2 is not a client/server application. It is simply a stand-alone
application the implements the logic of the mortgage calculator and provides a user interface.

2.   Client/Server Mortgage Calculator
a. In this part of the project you will write the client and server classes for the mortgage calculator.
You should write one class called CalculatorClient and another class celled CalculatorServer.
These classes can use the following protocol, which correspond to our three scenarios:

Client Request                                          Server Response
PAYMENT loanAmount rate years payments                    paymentAmount interestPaid totalPaid
YEARS loanAmount rate paymentAmount payments                     years interestPaid totalPaid
AMOUNT rate paymentAmount payments years                     loanAmount interestPaid totalPaid

b.   The CalculatorServer class should use the MortgageCalculator class you wrote for part 1. It
accepts requests from the CalculatorClient class, determines the correct response by using the
MortgageCalculator class, then sends the response to back to the CalculatorClient class.

c.   Write a class with a main method that provides a user interface for the client/server version of the
mortgage calculator. This interface can be exactly the same as the user interface you created in
part 1. However, now the user interface will be interacting with the CalculatorClient class, rather
than with the MortgageCalculator class.

3.   Replace the text-base user interface with a graphical user interface.
Required Formulas
There are three basic formulas you will need to write the application logic for the mortgage calculator.

fv = pv × (1 + intPeriod )
numPeriods
(1)

fv = pmt ×
(1 + intPeriod )numPeriods − 1
(2)
intPeriod

totalIntPa id = fv − pv                              (3)
Where:
pv = Loan amount (present value)
fv = Total amount paid to the bank (future value)
intPeriod = Interest rate per period
numPeriods = Number of periodic payments made
pmt = Amount of each periodic payment
totalIntPaid = Total interest paid

Using these equations, along with some algebra, the following useful equations can be obtained:

fv × intPeriod
pmt =
(1 + intPeriod)numPeriods − 1

 intPeriod × pv 
Log 1 −
                  

numPeriods = (− 1) ×              pmt      
Log (1 + intPeriod )

           pmt                
pmt − 
 (1 + intPeriod )numPeriods


pv =                                     
intPeriod
Example Calculations
Scenario 1 - Determine Monthly Payments for a Loan

Inputs
1) Loan amount = pv
2) Annual interest rate = intAnnual
3) Number of years = numYears
4) Payments per year = pmtsPerYear

Outputs
1) Amount of each payment = pmt
2) Total interest paid = totalIntPaid
3) Total amount paid = fv

Get Inputs & Calculate values needed to use formulas (1) and (2)

pv = \$100,000 intAnnual = 5% numYears = 30 pmtsPerYear = 12

Determine number of periods

Determine interest per period

Calculate Total Amount Paid

This is obtained from formula (1)

Calculate Total Interest Paid

This is obtained from formula (3). We can do this since pv is an input and we calculated fv in the
previous step.
Calculate Amount of Each Payment

We need to solve formula (2) for pmt

Scenario 2 - Determine Number of Years to Pay Off a Loan

Inputs
1) Loan amount = pv
2) Annual interest rate = intAnnual
3) Amount of each payment = pmt
4) Payments per year = pmtsPerYear

Outputs
1) Number of years to pay off the loan = numYears
2) Total interest paid = totalIntPaid
3) Total amount paid = fv

Get Inputs & Calculate values needed to use formulas (1) and (2)

The inputs: pv = \$100,000 intAnnual = 5% pmt = 536.82 pmtsPerYear = 12

Determine interest per period

Calculate Number of Years to Pay Off Loan

Using formulas (1) and (2) solve for number of periods to pay off loan

Convert that to years
Calculate Total Amount Paid

This is obtained from formula (1)

Calculate Total Interest Paid

This is obtained from formula (3)

Scenario 3 - Determine Loan Amount

Inputs
1) Amount of each payment = pmt
2) Annual interest rate = intAnnual
3) Payments per year = pmtsPerYear
4) Number of Years = numYears

Outputs
1) The amount of the loan I can afford = pv
2) Total interest paid = totalIntPaid
3) Total amount paid = fv

Get Inputs & Calculate values needed to use formulas (1) and (2)

The inputs: pmt = 536.82 intAnnual = 5% pmtsPerYear = 12 numYears = 30

Determine number of periods

Determine interest per period
Calculate Loan Amount

Using formulas (1) and (2) solve for present value

Calculate Total Amount Paid

This is obtained from formula (1)

Calculate Total Interest Paid

This is obtained from formula (3)

```
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
 views: 130 posted: 9/17/2008 language: English pages: 7
Description: This is an example of mortgage calculator what can i afford. This document is useful for studying mortgage calculator what can i afford.