Calculate and display mortgage payments

Assignment Help JAVA Programming
Reference no: EM131291768

Introduction to Programming

Java Programming Assignment: Objects and Decisions

Your last Alice program implemented decision making.

This assignment will apply the same concepts to Java, starting with the code from your last Java program (Java Assn 4), which implemented objects. The Java Assn 4 program ran all of the code sequentially.

Decision statements will now be used to run some of the statements conditionally, by implementing at least one of each of the following conditional programming constructs: if statement or if/else statement, multiple alternative if statement, nested if statement, and switch statement.

WARNING: Again, this assignment will be more challenging than the previous assignments, so make sure to start early and allocate enough time to complete it, including time you might need to seek any necessary help.

Problem Summary

Suppose you wanted to further modify your Mortgage Calculator, to make it more versatile. Starting with Java programming assignment 4, you could add the following features:

• Let the user decide on the down payment percentage amount to use.
• Calculate and display mortgage payments for both a 20-year and a 30-year loan, to allow the user to compare them.
• Have the program use the mortgage company's guidelines to set the interest rate for a mortgage.

o The mortgage company sets interest rates using the following chart, based on the length of a loan and the loan type.
o Loans up to $417,000 are called "conforming" loans. Loans over that amount are considered "jumbo" loans, and have different interest rates.

Interest Rate Chart

Conforming Loans

Jumbo Loans

30-year fixed

4.5%

4.125%

20-year fixed

3.85%

3.5%

Overview of Program

This program will still contain two classes, in two separate files within your project:

• A modified MortgageLoan class to define the data fields and methods for a MortgageLoan object, containing:

o Seven data field definitions for a MortgageLoan object
o Two constructor methods to create a MortgageLoan object (one constructor without parameters and one constructor with parameters).
o Six setter methods to set the values for six of the data fields
o An instance method to compute the monthly property tax.
o An instance method to compute the monthly insurance premium.
o An instance method to compute the monthly principle and interest loan payment.
o An instance method to display one loan's information.
o An instance method to calculate and display a loan's payment information.

• The main MortageCalculator class, modified to define only two methods, containing:

o A static method to display a description of what the program will do.
o A main method to display the program description, to read the inputs from the user, to create two MortgageLoan objects, and to call the other methods to display loan and payment information.

Program Requirements

Modify the program you wrote for Java Assignment 4, as follows:

1. Within the MortgageLoan class:

• Add the following additional private data field:

o char loan type (will store ‘C' for conforming or ‘J' for jumbo)

• Add a setter for the loan type data field. This method will:

o Define a local constant and set it to hold the upper limit for conforming loan amounts.
o Set the loan type data field to ‘C' for Conforming.

Then use an if statement to decide whether to re-set the data field to ‘J' for Jumbo, depending upon the value stored in the loan amount data field.

• Modify the setter for the loan identifier data field.

o The setter will now only have one parameter, the last name (will no longer use the zip code).
o The loan identifier field will be created using the first 6 letters (uppercased) of the last name.

- If the last name has less than 6 letters, the code should append Xs to the end of the name, so that there will be 6 letters total.

o Modify the body of the setter method to:

- Declare an integer constant to hold the loan identifier's String length of 6.
- Declare a second String constant to hold six Xs ("XXXXXX").
- Use these constants and the last name to create the loan identifier, WITHOUT using brute force.

o NOTE: You will need to check the length of the last name BEFORE trying to extract letters and then use a decision statement to decide which letters to extract. Otherwise the program may crash when there are less than 6 letters in the last name.

• Modify the setter for the loan annual interest rate

o The user will no longer enter the annual interest rate. Instead, the setter will use a nested if statement to set the annual interest rate data field, according to the chart on the previous page.

• Check the loan type data field.

• If the loan is a conforming loan, decide which rate to use based rates for conforming loans and the loan length data field.

• Otherwise, decide which rate to use based rates for jumbo loans and the loan length data field.

• Modify the setter for the down payment percent

o Add a char input parameter, to pass in the user's letter choice of down payment.
o Use a switch statement to set the down payment percentage as follows: N (no down payment) - set the percentage to 0
L (low down payment) - set the percentage to 10%
S (standard down payment) - set the percentage to 20% H (high down payment) - set the percentage to 30%

If the parameter contains any other letter, set the percentage to 0, and display an error message telling the user that since his/her choice was invalid, no down payment will be applied.

• Add a second constructor to instantiate a MortgageLoan type object. The new constructor with have four parameters:

o the home buyer's last name (String)
o the home value
o the down payment percentage choice (char)
o the loan length in years The constructor will:
o Assign values to the home value and loan length data fields, using the constructor parameters for the values.
o Call the modified setters for the loan identifier and the down payment percent, using the constructor parameter as the setter arguments.
o Call the original setter for the loan amount (no arguments - uses data fields values)
o Call the new setter for the loan type (no arguments - uses data field values).
o Call the modified setter for the loan annual interest rate (no arguments - uses data field values.

NOTE: The original getters for this class will no longer be necessary. All data fields will be accessed via the display instance methods.

• Modify the method that computes the insurance premium, so that it will decide what insurance rate to use.

o Instead of using a constant insurance rate (delete the defined constant), use a multiple alternative if statement to decide what rate to use, based on the down payment percentage, and store the value into a variable.

- For down payments of 10% or less, use a rate of 0.52%
- For down payments over 10%, up to 20%, use the rate from assignment 3 (0.49%).
- For down payments over 20%, use a rate of 0.47%.

• Convert the two static display methods from Java Assn 4 to be two instance methods within the

MortgageLoan class, as described below.

o Note that neither of these methods will require parameters, because the data fields can be accessed directly.

• The first instance method, displayLoanInfo, will:

o Display only the loan identifier, the loan amount and loan type.

- The loan amount should be displayed to 2 decimal places
- Use an if/else statement to display the loan type.
- Display "conforming" when the loan type is ‘C'
- Otherwise, display "jumbo"
- All values should line up with each other on the right, as shown below:

• The second instance method, calcAndDisplayPaymentInfo, will:

o Call each of the calculation instance methods (to compute the monthly taxes, insurance, and loan principle & interest payments) using this so that the calculations methods calls will use the same object as the calcAndDisplayPaymentInfo method.

- Save the results returned from the calls to each calculation method, and then compute the total monthly mortgage payment.

o Modify the display of the loan length, annual interest, and monthly mortgage payment parts and total, to look like this:

- Each of these lines should be indented by 2 spaces
- The loan length should be displayed in whole years.
- The annual interest rate should be displayed to 3 decimal places and be followed by a percent sign (%).
- All dollar figures should be displayed to 2 decimal places, lined up on the decimal points.
- All values should line up with each other on the right, and also line up with the loan identifier, amount, and type displayed from the displayLoanInfo method.

After creating the above two instance methods, be sure to delete the static display methods from the

MortgagCalculator class.

2. Within the original class MortgageCalculator class that contains the main method:

• Modify the main method to:

o Still display the program description, as in Java Assignment 4.
o Modify what data is read from the user.

- Read the home buyer's last name, as in Java Assignment 4.
- Remove the code that reads the zip code.
- Read the home value, as in Java Assignment 4.
- Remove the code that reads the annual percentage rate from the user.
- Read the down payment choice (as shown in the Sample Inputs below), as follows:

• Display a menu to the user, with letters as choices.
• Prompt for the user's choice, and read the letter chosen by the user.

Debugging and Testing

Run, test, and debug your Java program, until you confirm that all of the decision control structures work. Be sure to test your program with different inputs to make sure it provides correct results.

Submission

This programming assignment is due by midnight of the date listed in the Course Assignments by Week.

Again, you will submit a single zip file containing all of the files in your project.

• First export your project from NetBeans:

o Highlight the project name.
o Click on File from the top menu, and select Export Project.
o Select To ZIP
o Name your export file in the following format:
<lastname>Assn<x>.zip
For example:
SmithAssn5.zip

NOTE: Save this zip file to some other directory, not your project directory.

• Then submit your .zip file to the Java Prog Assn 5 assignment submission folder (located under the Assignments/Dropbox tab in the online course).

o Warning: Only NetBeans export files will be accepted.

Do not use any other kind of archive or zip utility.

Attachment:- Java Porgram.rar

Reference no: EM131291768

Questions Cloud

Prepare a swot matrix and a space matrix : Prepare a SWOT Matrix, a SPACE Matrix, BCG Matrix, IE Matrix, and Grand Strategy Matrix for the assigned company.
Create the necessary ruleset to use within snort to fire : Create the necessary ruleset to use within Snort to fire an alert whenever an attempt is made to connect to, access, browse, or otherwise visit the site you have chosen.
Discuss about the counseling psychology : Discuss about the Counseling Psychology.Comparison of salaries at the entry level to the tenured employee level Field: Counseling Psychology
Type of architecture the new payroll application : Explain what type of architecture the new payroll application should use and why. Identify what types of technology will be involved in the architecture and explain the purpose of each technology. Create a graphical representation of your recommended..
Calculate and display mortgage payments : Let the user decide on the down payment percentage amount to use. Calculate and display mortgage payments for both a 20-year and a 30-year loan, to allow the user to compare them.
Create an organizational chart to represent ideal structure : Create an organizational chart to represent the ideal structure for your current organization.- The benefits of the selected structure.
Number of bytes being captured : What are some causes of the number of bytes on the wire exceeding the number of bytes being captured?
Discuss methods to measure the level of success : Examine the role of industrial/organizational psychology in selecting and training employees.Discuss methods to measure the level of success,Discuss any legal and/or ethical concerns that may arise in the implementation of each training program.
Perform a full backup of the adventureworks database : 1. Take the command that you made to reorganize your Production.TransactionHistory table, and schedule it to run as a weekend job Sunday mornings at 2AM. 2. Perform a full backup of the AdventureWorks database. Save the backup to C:MyBackup.bak (o..

Reviews

Write a Review

 

JAVA Programming Questions & Answers

  Writing a simple gui application using a class called myguic

writing a simple GUI application using a class called MyGuiClass. Your GUI will have a JButton which your program will need to respond to when it is clicked. Describe what you would need to do to setup event handling using a nested inner class. Use J..

  Information from the user and prints a payroll statement

Write a program that accepts the following information from the user and prints a payroll statement

  Write a class that reads a file

In java, write a class that reads a file and outputs a list of the unique words in the file and the number of times each unique word occurs.Hint: use a HashMap with keys being the words and values being integer counts associated with the words.

  Natural sympathies

Discussed the "natural sympathies" and equality that exist between Jane and Mr. Rochester and that challenge the rigid class structure of English society.

  Demonstrate your knowledge in a pragmatic way

Summarize everything that we have addressed in the XML Applications course, and provide a mechanism to demonstrate your knowledge in a pragmatic way.

  Redesign the grading program as an object-oriented design

Redesign the grading program as an object-oriented design. We will start with a simple Student class. The student will have a name, an id (as a String) and a set of grades (as doubles).

  Implementation of the vector data type

Described in general terms the implementation of the vector data type. Complete the implementation of the vector by providing definitions for the subsequent operations

  Modify the java application using java netbeans ide

Modify the Java application using Java NetBeans IDE to meet these additional and changed business requirements

  What can a catch block do with the exception object

What can a catch block do with the exception object that it receives and write lines of code to create object input and output streams for the file c:\temp\mydata.out

  Write java application that effectively uses java collection

Write a Java application that effectively uses Java collections to store up to 20 instances of the Person class and its subclasses. Then write a GUI that displays the Person names using radio buttons to select a value

  Create a servlet that displays a form when the doget method

Create a Servlet that displays a form when the doGet method is invoked. The form will contain a post action that directs the form post back to the same servlet, which in the doPost method will append the form data to a random access file. After th..

  Determine the percentage of vowels

Create a Java program that asks the user to input a sentence in any language, counts the number of vowels in the sentence, divides it by the total number of characters in the sentence.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd