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

  Unique index integer fields

Unique index integer fields Use at least 5 other fields of various, including at least one of each of String, int and double types. assume that the String's have no spaces within them

  Why restriction is necessary for recursive descent parsing

The second restriction is that the grammar must not require more than one token look ahead. Give an example of a production that does not have this property. Explain why this restriction is necessary for recursive descent parsing

  How threads are used to implement currency in java

Describe the concept of concurrency and how threads are used to implement currency in Java

  Develop parent lock method asks for four digit password

Develop the parent lock method (turns lock on/off) which asks for 4 digit password. Navigating to any channel which is in range 99-110 must ask for password when parent lock is on.

  In java programming what is the size of double variable

In java programming What is the size of double variable?

  Design a class named pet

Design a class named Pet, which should have the following fields: Name - The name field holds the name of a pet. Type - The type field holds the type of animal that is the pet. Example values are "Dog", "Cat", and "Bird".

  A client or server prepare to use udp in a java application

How does a client or server prepare to use UDP in a Java application? Are there any differences in what the client does and what the server does?

  Rewrite this code in order to ask the user for input

rewrite this code in order to ask the user for input and then coverth it from infex to postfix ,, so i want to put a Scanner and this ask the user for input .. how to do it ?

  Calculate rental fee for different types of borrowable media

Assume that there is an abstract class called Vehicle, which has two concrete subclasses, Car and Truck. There is also an interface Loadable, which only Truck implements - calculate a rental fee for different types of borrowable media (e.g. books,..

  A regular polygon is an n-sided polygon

A regular polygon is an n-sided polygon in which all sides are of the same length and all angles have the same degree(i.e the polygon is both equilateral and equiangular).

  Write a program that displays the squares

Using a for loop, write a program that displays the squares of all integers greater than 0 and less than or equal to a given number n. Use the c ++ programming language to write the code.

  Creates a professorraing class

Write a program that creates a professorRaing class consisting of professor ID and three ratings. The three ratings are used to evaluate easiness, helpfullness, and clarity. In a separate implementation class, allow the user to enter the values.

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