Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

Java Programming Assignment: Objects and Instance Methods

All of your Alice programs have been using objects already. And the predefined function and procedure methods in Alice are equivalent to instance methods for those objects in Java. You also defined your own methods within an Alice class, which had to be applied to a specific object in order to run.

This assignment will apply the same concepts to Java. You will create a new class, and use the new class to create an object in Java. Methods defined within the new class (instance methods, similar to the Alice procedure and function methods) will be called using the dot (.) operator, to send a message to the object.

WARNING: 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 modify your Mortgage Calculator from Java programming. You could:

• Store all the previous data about one mortgage loan as data fields within an object
• Add a mortgage loan identifier data field
• Revise the calculation methods to be instance methods within the object's class

o NOTE: This will eliminate the need to pass the loan data into the methods via parameters.

Since you will be modifying your Mortgage Calculator program, make sure you use your instructor's feedback to fix any mistakes.

Overview of Program

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

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

o Six data field definitions for a MortgageLoan object
o A constructor method to create a MortgageLoan object
o Four setter methods to set the values for four of the data fields
o Four getter methods to get the values of four 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.

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

o A main method to display the program description, create an object, read the inputs from the user, and call the other methods.
o A static method to display a description of what the program will do.
o A static method to display loan details.
o A static method to calculate and display the results of the program.

Since there will be multiple files, the program will be submitted via a .zip file (see last page).

Program Requirements

Modify the program you wrote for Java Assn 3, as follows:

1. Define an additional Java class (File | New File | Java Class) named: MortgageLoan

Within the MortgageLoan class, define the following private data fields to store properties about the mortgage loan:

• loan identifier (String) ← new!
• home value
• down payment (double value that will hold a whole number percent of home value, e.g. 10.0)
• loan amount
• length of loan (in whole years)
• loan annual interest rate (floating point percentage, e.g. 4.5)

Remember that all private data fields defined at the class-level can be accessed by any method within the same class (without parameter passing).

Also within the new MortgageLoan class, you will define instance methods that can be used with an object of the MortgageLoan class, as follows:

• Define a default constructor with no parameters that will create the object with the following initial data values set:

Loan identifier set to "" (an empty String)

Home value, loan amount, and interest rate all set to 0.0 Down payment set to 10%

Loan length set to 30 years

• Create setters for the following data fields:
o Setter for loan identifier

- Input parameters will be two Strings: the home buyer's last name and zip code.
- Use the built-in Java String methods to uppercase and extract the first 4 letters of the last name and concatenate them with the last 3 digits of the zip code to create the loan identifier.
- Set the loan identifier data field to this value.

o Setter for home value

- Input parameter will be home value.
- Set the home value data field to the parameter value.

o Setter for loan amount

- No parameters
- Calculate the loan amount using the home value and the down payment percent data fields. Be sure to convert the down payment from whole number value to a value that can be used in a math formula.
- Set the loan amount data field to the calculated value.

o Setter for loan annual interest rate

- Input parameter will be the annual interest rate.
- Set the loan annual interest rate data field to the parameter value

• Create getters for the following data fields in the MortgageLoan class:

o loan identifier (String)
o loan amount
o length of loan (in years)
o loan annual interest rate (percentage)

Each of the getters should return the data field's current value.

• Move the calculation methods (methods 2 - 4) from Java Assn 3 from the MortgageCalculator class to the MortgageLoan class. Then modify them, so they can be used as instance methods in the new MortgageLoan class, as follows:

o Eliminate the parameter lists from each method (parameters will no longer be necessary).
o Keep all constants previously defined in the methods, except for the number of loan months defined in method 4.

- Use the loan length data field from the object to calculate the number of months in the loan, instead of the previous constant value.

o Modify the formulas to use the object data fields, instead of parameters.

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

• Make sure you deleted the old static calculation methods when you moved them to the MortgageLoan class.
• Modify the main method to perform the following additional tasks:

o After displaying program description, create an object of the new MortgageLoan class type.
o Prompt for (using descriptive prompts) and read:

- the home buyer's last name (you can assume there will be no spaces in the last name and it will contain at least 4 letters).
- the home buyer's zip code

o Same as before, prompt for (using descriptive prompts) and read the home value and the annual interest rate.

Attachment:- morgage_0.rar

Java, Programming

  • Category:- Java
  • Reference No.:- M92054321
  • Price:- $40

Priced at Now at $40, Verified Solution

Have any Question?


Related Questions in Java

Assignment game prototypeoverviewfor this assessment task

Assignment: Game Prototype Overview For this assessment task you are expected to construct a prototype level/area as a "proof of concept" for the game that you have designed in Assignment 1. The prototype should function ...

In ruby the hash class inherits from enumerable suggesting

In Ruby, the Hash class inherits from Enumerable, suggesting to a programmer that Hashes are collections. In Java, however, the Map classes are not part of the JCF (Java Collections Framework). For each language, provide ...

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

Question slideshows or carousels are very popular in

Question : Slideshows (or carousels) are very popular in websites. They allow web developers to display news or images on the website in limited space. In this code challenge, you are required to complete the JavaScript ...

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

Can someone kindly help me to consider whether java

Can someone kindly help me to consider whether Java provides the facility of operator overloading? If it does, may you kindly describe how overloading operators can be accomplished? If not, may you kindly describe why yo ...

Project requirementsfor the problem described in the next

Project requirements For the problem described in the next section, you must do the following: 1. include your student ID at the end of all filenames for all java code files. Three classes have been identified in section ...

Solving 2nd degree equationsbull write the following java

Solving 2nd degree equations • Write the following Java methods • boolean real-sols(double a, double b, double c): it returns true if the 2nd degree equation ax2 + bx + c has real solutions • double solution1(double a, d ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As