Create two house object using constructor with two parameter

Assignment Help JAVA Programming
Reference no: EM131374124

Java- House

General description for homework 8: In this homework, you need to first develop a class using OOP principles: data abstraction and encapsulation, and then create an application class to make use of the encapsulated class developed above. Therefore, after finishing this homework, you demonstrate your skill in the development and use of OOP class. Here is the detail description for homework 8: Create a Java project in Eclipse. This project has two java files (classes): House.java and JohnDoeHw8.java : First, create a new java file named House.java.

At the beginning of this file, add an appropriate program header similar to what you did in "homework 1--part B--step 3". Then, right after the program header is the definition line for public class House. Then in the body of this class House, do the following:

1. define two private data member: total price of double type (for example, a value of 168000 indicates that this house is worth 168000 dollars), and total square feet of double type (for example, a value of 2398 indicates that this house has 2398 square feet in total).

2. define two public constructors, the first one is the default constructor with no parameter, and the second one has two parameters to initialize the two private data members of this class.

3. for every data member, provide a public getter and a public setter, so there are two getters and two setters in total. Refer to textbook sec 8.9 for formal definition of getter and setter. Or refer to the modified TV.java for examples of getter and setter.

4. provide a public method named calcPricePerSqf . This method returns the average price per square foot of the house by dividing the total price by the total square feet. The return type of this method is double. This method does NOT need any formal parameter, because as a public member method, this method can directly access the private data members of the same class.

5. provide a public method named calcPropertyTax. This method returns a double type value, which is the property tax of this house.

This method needs only ONE formal parameter, which is a double type variable named taxPercentage. The property tax of the house is calculated by multiplying the total price of the house (a private data member of the class) with the tax percentage (the formal parameter of this method). For example, if the tax percentage is 1.25 percent for a house of 160000 dollars, then the property tax is 160000 * 1.25 * 0.01 = 2000 dollars. Notice that the 0.01 in the above formula is to convert the 1.25 percent to the real value.

Attention: taxPercentage is a formal parameter of this method, and it is NOT a data member of the House class, therefore, do not make the mistake of setting taxPercentage as a private data member of the House class, and if you do that, you are in the wrong track!!!! Secondly, create a new java file named JohnDoeHw8.java, which has the application class JohnDoeHw8 (replace JohnDoe with your first and last name). At the beginning of JohnDoeHw8.java, add an appropriate program header as what you did in "homework 1--part B -- step 3".

This class has only one method name main, and in the first line of the main method, insert a statement to output your name, course section and semester info, and refer to "homework 1 -- part B -- step 4" for the same requirement of this output line. Then do the following:

1. create two House objects using the constructor with two parameters, plug in the data below as the actual parameters of the constructor. Each line below contains the two actual parameters for one object: 295000.0 3395.0 189000.0 1675.0 , where the 1st column is total price, and the 2nd column is total square feet. Refer to the modified TestTV.java file, on how tv3 object is created.

2. create the third House object using the default constructor. Then ask the user to input the two parameters with a Scanner type variable, and no GUI input is needed. Then use the setters to set the user input values into the third object object. No data type or range checking of the input parameters is needed. Refer to the modified TestTV.java file, on how tv1 object is created.

3. ask the user to input a tax percentage. For example, a user input of 1.25 means 1.25%. This property tax value will be used in the next step to calculate the property taxes for all three house objects.

4. For each individual House object, invoke two methods: calcPricePerSqf () and calcPropertyTax() and store the results in two local variables, respectively. For method calcPropertyTax, you need to plug in the tax percentage variable obtained in step 3 above. In summary, you have 6 variables that store the results for three house objects.

5. For each house object, output its total square feet, total price, average price per square feet, and the property tax. If the output information exceeds 80 columns, you need to output them in multiple lines, with each line less than 80 columns.

Use System.out.printf() method, and format the total square feet with one digits after the decimal point, and the other three output items with two digits after the decimal point (because they are money values).

Assume that the total square feet in each house object is less than 10000 square feet, and the total price of each house is less than 1000000 dollars. Implementation requirements:

• No need to use array in this homework.

• File House.java contains only one class named House, and file JohnDoeHw8.java contains only one class named JohnDoeHw8. File House.java and file JohnDoeHw8.java are two different java files.

• In file House.java, you need to have two private data members, and all methods are public, including: two constructors; one setter and one getter for each private data member; method calcPricePerSqf () and method calcPropertyTax().

• When coding House.java, please refer to file "CorrectSequence.java" in folder "chap8" for the correct sequence of components in an encapsulated class. The modified TV.java follows the correct sequence strictly, which also serves as a reference.

• In file you have only one method: the main method.

• The signature and return type of the methods in these two classes have already been defined in the above homework descriptions, and you cannot change the signature and the return type of any method.

• Add suitable comments in the source code.

• Please read the above implementation details carefully BEFORE start coding.

• As a general reference, read the modified source code files: TV.java and TestTV.java on how to code class with OOP principle and how to code application class that uses OOP class.

• After finishing coding, you need to debug your program and test it multiple times with different input parameters supplied for each test run.

Reference no: EM131374124

Questions Cloud

Evaluate the benefits and costs and risks associated : Evaluate the benefits, costs, and risks associated with doing business in each nation. Which country seems the most attractive target for foreign direct investment? Why?
What are the impediments to completing the transformation : What kind of economic system did India operate under during 1947-1990? What kind of system is it moving toward today? What are the impediments to completing this transformation?
What is the purpose of an aquastat : What are the typical pressure settings for a pressurereducing valve and system relief valve in a hot-water oil-fired boiler?
Suggest ways to identify points of agreement : Your purpose is to analyze at least two essays/TED Talks to understand their authors' main points of disagreement and to suggest ways to identify points of agreement and build common ground based on shared values, concerns, needs, and interests, a..
Create two house object using constructor with two parameter : Create two House objects using the constructor with two parameters, plug in the data below as the actual parameters of the constructor. Each line below contains the two actual parameters for one object.
Why has the japanese economy stagnated : In the 1980s Japan was viewed as one of the world's most dynamic economies. Today it is viewed as one of its most stagnant. Why has the Japanese economy stagnated?
How is an oil furnace heat exchanger shaped : What is the typical output pressure of an oil-fired furnace oil pump?
What is the advantage of a high-pressure oil burner : Compare the efficiency of a mid-efficiency oil furnace to an older, traditional oil furnace.
Outline why the culture of a country might influence cost : Outline why the culture of a country might influence the costs of doing business in that country. Illustrate your answer with examples.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

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