Define a default constructor with no parameters

Assignment Help JAVA Programming
Reference no: EM131299673

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

Reference no: EM131299673

Questions Cloud

Conduct a branded and unbranded experiment : Choose a product. Conduct a branded and unbranded experiment.- What do you learn about the equity of the brands in that product class?
Does the firm appear to have an agency problem : Evaluate the firm's approach to pollution control. Does it seem to be ethical? Why might incurring the expense to control pollution be in the best interests of the firm's owners despite its negative effect on profits?
What do you think of the interbrand methodology : How do you think Young & Rubicam's Brand Asset Valuator relates to the Interbrand methodology? What do you see as its main advantages and disadvantages?
Images or diagram of sample products : For your midterm project complete the following using screenshots, images or diagram of sample products, processes, etc. to illustrate and descriptive texts to address the items below (you may also consult YouTube.com as a source) This is not a re..
Define a default constructor with no parameters : 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).
How would you improve the companys branding strategies : Pick a company:- As completely as possible, characterize its brand portfolio and brand hierarchy. How would you improve the company's branding strategies?
Mining hidden value in deep web-challenges and opportunities : In the answer you should Demonstrates a commendable ability to engage independently in investigating and researching material with a breadth of reading substantiated with credible and accurate referencing.
Contrast the branding strategies and brand portfolios : Contrast the approach by Anheuser-Busch and its Budweiser brand with that of Kellogg in the ready-to-eat cereal category.
Some of product strategies and communication strategies : What are some of the product strategies and communication strategies that General Motors could use to further enhance the level of perceived differentiation between its divisions?

Reviews

Write a Review

JAVA Programming Questions & Answers

  Create an interface called transcripts

You are going to create an interface called Transcripts with 2 methods: getGPA() and getTotalCredits(). Implement these methods in the Student class you created for Assignment

  Enterprise java beans (ejb) in software development

Enterprise Java Beans (EJB) in software development, EJB technology, EJB application, Stateless Session Beans (SLSB), Stateful Session Beans (SFSB), Message Driven Bean (MDB), Entity Bean

  Program to replace a number with the new one

It will return a value of 42 at the point of call, because the first value of 21 in x gets overwritten by the new value 42

  Write program that that displays jframe window with buttons

Write a program that that displays a JFrame window with 5 buttons. The buttons will be used to control the background color. The button's text will be randomly chosen from 5 colors and the background color will change to the color shown on the button

  Create set methods for color and height, but not for price

Create a class for the business named Candle that contains data fields for color, height, and price. Create get methods for all three fields

  Insert in order functionality to your statistics program

You are to add mean, standard deviation, and insert in order functionality to your statistics list program.

  Create a javafx application named runningman.java

Create a JavaFX application named RunningMan.java to animate a man running laps. The man should run from left to right until the edge of the window is reached. The man should then begin running in the opposite direction.

  What are the three types of errors

What are the three types of errors that you can encounter in a Java program? Describe them, and explain how you would minimize the errors

  Write a java program to simulate a die

Write a Java program to simulate a die. A die has values of either 1, 2, 3, 4, 5 or 6 on the face. You should use the Math.Random() or the java.util.Random() class to generate the values on the die. The program should prompt the user to enter how ..

  Alter the prototype form page by javascript function

Alter the prototype form page so that when JavaScript function has verified that all the required fields have been filled, cookie is added to user's computer.

  Write a java sorting application with two classes

Write a Java Sorting Application with two classes, JavaSort and JavaSortTest. Your JavaSort Class, as a minimum must contain sorting methods for BubbleSort, InsertionSort, ShellSort, MergeSort, and QuickSort.

  Write a string expression that parenthesizes the value

Given a string varible word, write a string expression that parenthesizes the value of word. So if the word contains "sadly" the value of the expression would be the string "(sadly)".

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