Question

Write a complete Java program with OO classes The code should have: A super class named Home Properties address SF (this is the number of Square feet) value (this is the dollar value of the home) P...

Write a complete Java program with OO classes

The code should have:

  1. A super class named Home
    • Properties
      • address
      • SF (this is the number of Square feet)
      • value (this is the dollar value of the home)
      • PPSF (price per square foot) you will calculate this in a method
    • Methods
      • Set and get methods for all properties
      • CalcPPSF - (PPSF is the value/SF)
  2. A sub class named Condo, which has one more HOA property:
    • Property:
      • HOAfee (home owners association fee)
    • Methods
      • Set and get methods
  3. A DemoCondo class, which is used to test your classes:
    • Create 10 Condo objects in an array (use a loop)
    • The addresses are 101 thru 110 Hardscrabble Drive
    • The SF are all 1150
    • The values are all $450,000
    • Use the calcPPSF method to fill the PPSF
    • The HOAfees are all $350
    • Output the contents of the array to the console after you have filled the array.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

class Home // base class
{
   private String address;
   private int SF;
   private double value;
   private double PPSF;
  
   //set and get methods
   public void setAddress(String address)
   {
       this.address = address;
   }
   public void setSF(int SF)
   {
       this.SF = SF;
   }
   public void setValue(double value)
   {
       this.value = value;
   }
   public String getAddress()
   {
       return address;
   }
   public int getSF()
   {
       return SF;
   }
   public double getValue()
   {
       return value;
   }
   public double calcPPSF()
   {
       return value/SF;
   }
   public String toString()
   {
       return "\nHome Address : "+address +" Square Feet : "+SF +" value : $"+value +" price per square feet : $"+calcPPSF();
   }
}

class Condo extends Home // derived class
{
   private double HOAfee;
  
   public void setHOAFee(double HOAfee)
   {
       this.HOAfee = HOAfee;
   }
   public double getHOAFee()
   {
       return HOAfee;
   }
   public String toString()
   {
       return super.toString()+" HOA fee : $"+HOAfee;
   }
}

class DemoCondo
{
   public static void main (String[] args)
   {
      
       Condo[] condo = new Condo[10];
       int addr = 101;
      
       for(int i=0;i<10;i++)
       {
           condo[i] = new Condo();
           condo[i].setAddress(addr+" Hardscrabble Drive");
           addr++;
           condo[i].setSF(1150);
           condo[i].setValue(450000);
           condo[i].setHOAFee(350);
           condo[i].calcPPSF();
       }
      
       for(int i=0;i<10;i++)
       {
           System.out.println("Condo "+(i+1)+condo[i]);
       }

   }
}

Output:

Condo 1
Home Address : 101 Hardscrabble Drive Square Feet : 1150 value : $450000.0 price per square feet : $391.30434782608694 HOA fee : $350.0
Condo 2
Home Address : 102 Hardscrabble Drive Square Feet : 1150 value : $450000.0 price per square feet : $391.30434782608694 HOA fee : $350.0
Condo 3
Home Address : 103 Hardscrabble Drive Square Feet : 1150 value : $450000.0 price per square feet : $391.30434782608694 HOA fee : $350.0
Condo 4
Home Address : 104 Hardscrabble Drive Square Feet : 1150 value : $450000.0 price per square feet : $391.30434782608694 HOA fee : $350.0
Condo 5
Home Address : 105 Hardscrabble Drive Square Feet : 1150 value : $450000.0 price per square feet : $391.30434782608694 HOA fee : $350.0
Condo 6
Home Address : 106 Hardscrabble Drive Square Feet : 1150 value : $450000.0 price per square feet : $391.30434782608694 HOA fee : $350.0
Condo 7
Home Address : 107 Hardscrabble Drive Square Feet : 1150 value : $450000.0 price per square feet : $391.30434782608694 HOA fee : $350.0
Condo 8
Home Address : 108 Hardscrabble Drive Square Feet : 1150 value : $450000.0 price per square feet : $391.30434782608694 HOA fee : $350.0
Condo 9
Home Address : 109 Hardscrabble Drive Square Feet : 1150 value : $450000.0 price per square feet : $391.30434782608694 HOA fee : $350.0
Condo 10
Home Address : 110 Hardscrabble Drive Square Feet : 1150 value : $450000.0 price per square feet : $391.30434782608694 HOA fee : $350.0

Do ask if any doubt. Please upvote.

Add a comment
Know the answer?
Add Answer to:
Write a complete Java program with OO classes The code should have: A super class named Home Properties address SF (this is the number of Square feet) value (this is the dollar value of the home) P...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a complete Java program to do the following Your code should have: A super class...

    Write a complete Java program to do the following Your code should have: A super class named Home Properties address SF (this is the number of Square feet) value (this is the dollar value of the home) PPSF (price per square foot) you will calculate this in a method Methods Set and get methods for all properties CalcPPSF - (PPSF is the value/SF) A sub class named Condo, which has one more HOA property: Property: HOAfee (home owners association fee)...

  • Code a Java program to create and use OO classes. Comment your code throughout. Create a...

    Code a Java program to create and use OO classes. Comment your code throughout. Create a Super class named Home Properties address SF (this is the number of Square feet) value (this is the dollar value of the home) Methods Set and get methods for all properties calcValue() - calculate the value as sf * 400 displayCondo() - displays all properties of a condo Create a sub class named Condo Properties HOAfee (home owners association fee) Methods Set and get...

  • Assignment Requirements I have also attached a Class Diagram that describes the hierarchy of the inheritance...

    Assignment Requirements I have also attached a Class Diagram that describes the hierarchy of the inheritance and interface behaviors . The link to the PDF of the diagram is below MotorVehical.pdf Minimize File Preview User Define Object Assignment: Create a Intellij Project. The Intellij project will contain three user defined classes. The project will test two of the User Define Classes by using the invoking each of their methods and printing the results. You are required to create three UML...

  • Complete the code in C#. Part 1 is one program. Part 2 is another program. They're...

    Complete the code in C#. Part 1 is one program. Part 2 is another program. They're seperate programs, but use part 1 to figure out part 2. Part! Create a new console application named Demojobs. Write a program for Harold's Home Services. The program should instantiate an array of job objects and demonstrate their methods. The Job class contains four data fields-description (for example "wash windows), time in hours to complete (for example 3.5), per-hour rate charged (for example, $25.00),...

  • Please use Java to write the program The purpose of this lab is to practice using...

    Please use Java to write the program The purpose of this lab is to practice using inheritance and polymorphism. We need a set of classes for an Insurance company. Insurance companies offer many different types of policies: car, homeowners, flood, earthquake, health, etc. Insurance policies have a lot of data and behavior in common. But they also have differences. You want to build each insurance policy class so that you can reuse as much code as possible. Avoid duplicating code....

  • the first question java code eclipse app the second question is java fx gui caculator please...

    the first question java code eclipse app the second question is java fx gui caculator please fast 1. Create project called "YourFirstName_QUID'. Eg. Aliomar_202002345 2. Create two package Q1 and Q2. 3. Add your name and studentID as comments on the top of each Java source file you submit. Question 1. Bookings APP [80 Points-six parts] Implement the following hotel booking system. Use the following class diagram to understand the structure of the system's classes, their attributes operations (or methods),...

  • Additional code needed: PartA: BurgerOrder class (1 point) Objective: Create a new class that represents an...

    Additional code needed: PartA: BurgerOrder class (1 point) Objective: Create a new class that represents an order at a fast-food burger joint. This class will be used in Part B, when we work with a list of orders. As vou work through this part and Part B, draw a UML diagram of each class in using the UML drawing tool 1) Create a new Lab5TestProject project in Netbeans, right-click on the lab5testproject package and select New>Java Class 2) Call your...

  • starter code To write a program using the starter code which is TestLinkedList to see if...

    starter code To write a program using the starter code which is TestLinkedList to see if the LinkedList program has bugs. It will produce ether a pass or fail.More information is in the first two pictures. LinkedList.java /** * @author someone * * Implements a double-linked list with four errors */ public class LinkedList<E> { // The first and last nodes in the list private Node<E> head, tail; // Number of items stored in the list private int size; //...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT