Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

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.

Java, Programming

  • Category:- Java
  • Reference No.:- M92183959
  • Price:- $75

Guranteed 36 Hours Delivery, In Price:- $75

Have any Question?


Related Questions in Java

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

Assessment instructionsin this assessment you will design

Assessment Instructions In this assessment, you will design and code a simple Java application that defines a class, instantiate the class into a number of objects, and prints out the attributes of these objects in a spe ...

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 ...

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 ...

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 ...

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 ...

Operating systems assignment -problem 1 sharing the bridgea

Operating Systems Assignment - Problem 1: Sharing the Bridge A new single lane bridge is constructed to connect the North Island of New Zealand to the South Island of New Zealand. Farmers from each island use the bridge ...

Answer the following question whats the difference public

Answer the following Question : What's the difference public inheritance and private inheritance? What can derived classes inherit from base classes? What cannot be inherited from base classes?

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 ...

  • 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