Programming Assignment # 2     

Java concepts required:

Console I/O (System.out.println, Scanner or BufferedReader – no GUI I/O is allowed)

Computational statements using arithmetic operators

Format console output

Program Specifications

Implement a simple mortgage calculation program that helps perspective borrowers calculate monthly mortgage payments and property tax. The program will start out by asking for property zip code, property’s full address, annual interest rate (in percentage), number of years to pay off the loan, property’s value and finally percentage of down payment. It will then move on to calculate the loan amount, monthly mortgage payment, total monthly payment including property tax and total payment over the loan period. Finally the program will display the results of its calculations.

Sample run of the mortgage calculation program: (bold-face is user input)

Enter property zip code: 95148

Enter property address: 2613 Aborn Rd, San Jose CA

Enter property offer price: $312500

Enter down payment (in percentage %): 20.0

Enter number of years financing: 15

Enter annual interest rate (in percentage %): 5.75

Mortgage calculator is processing your data …  Please wait …

lab 2-1.JPG

NOTE: The decimal points for double values should be all aligned in your program output or point deduction may apply.

Class Design

None. Only one public class containing the main method (as seen above) is needed.

Program Structure

In the main method the program flow must be properly structured as shown below:

variable declarations (should declare all variables together, including variables that hold intermediate results if any, at the beginning of the main method).
obtain user input such as property zip code, address, property offer price, down payment percentage, annual interest rate and number of years financing using input statements. You may assume users will enter correct data for your program. No need to perform data validation.
pause the program to simulate a delay due to calculation (see note at the end of the specs).
perform loan calculations.
output the results.
Implementation/Coding Requirements

Must provide program description/history comment.
The public class name must be tied to the program. Naming such as: class SecondAssignment, class CS1AAssignment2, class MyProgram should be avoided or point deduction may apply.
Declare and initialize descriptive local variables at the beginning of the main method.
Class and variable names must follow Google naming convention.
Must use the right data type for different kinds of data. For example must use int for number of years, not double or must use double or float for loan amount, not int.
Output must be aligned and formatted nicely as shown above.
Note: Generally it’s considered a bad programming practice and low maintainability to input one single data then do some computation then input another single data then do some computation. It will be much easier for debugging and maintainability purposes to input all data together at once then perform all calculations as indicated in the main function program’s flow above. Failure to do this will result in heavy point deduction.

Mortgage Payment Calculation Formulas

You can assume the property’s tax rate is fixed at 1.5 %. Define a constant double variable to represent this value.
Total down payment: property offer price x down payment (in %) / 100
Loan amount = property offered price – total down payment
Loan maturity date = 12/31/(2023 + number of years financing)      NOTE: 12/31 is fixed – you only need to compute 2023+number of years financing
Monthly interest rate = annual interest rate / 1200
Monthly mortgage payment = loan amount x monthly interest rate /  ( 1 –  1 / Math.pow (1+ monthly interest rate, number of years financing * 12) )
Monthly property tax = offered price x property’s tax rate / 100 / 12
Total monthly payment (property tax included) = monthly mortgage payment + monthly property tax
Total payment (exclude tax) = monthly mortgage payment x 12  x  number of years financing
NOTE: Values in italics are intermediate: Monthly interest rate and Monthly property tax.

Code Helper

To pause your program: add the following code to your program after output the string “Mortgage calculator is processing your data. Please wait …”

try {
    Thread.sleep (3000);  // sleep for 3 seconds.
}
catch (Exception e ) {
    e.printStackTrace ( ); 
}
Testing

Run your program three times. First use the sample information above. If the result comes out similar to the sample output (it’s ok if your results are off a couple of cents, not a couple of dollars) you’re pretty much confident your program works as expected. Then run it with two more set of data. Remember to submit all three outputs. Missing a test case will result in 5 points deduction.

Subscribe For Latest Updates
Let us notify you each time there is a new assignment, book recommendation, assignment resource, or free essay and updates