Question

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:

  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)

  1. A sub class named Condo, which has one more HOA property:
    • Property:
      • HOAfee (home owners association fee)
    • Methods
      • Set and get methods

  1. 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
{
int address;
int SF;
double value;
double PPSF;

void setAddress(int address)
{
this.address=address;
}
void setSF(int SF)
{
this.SF=SF;
}
void setValue(double value)
{
this.value=value;
}
int getAddress()
{
return address;
}
int getSF()
{
return SF;
}
double getValue()
{
return value;
}

double calcPPSF(int SF,double value)
{
PPSF=value/SF;
return PPSF;
}
double getPPSF()
{
return PPSF;
}
}
class Cando extends Home
{
int HOAfee;
void setHOAfee(int HOAfee)
{
this.HOAfee=HOAfee;
}
int getHOAfee()
{
return HOAfee;
}
}
public class DemoCondo
{
public static void main(String args[])
{
Cando[] c=new Cando[10];
for(int i=0;i<10;i++)
{
c[i]=new Cando();
c[i].setAddress(101+i);
c[i].setSF(1150);
c[i].setValue(450000);
c[i].PPSF=c[i].calcPPSF(1150,450000);
c[i].setHOAfee(350);
}
System.out.println("ADDRESS\tSF\tVALUE\t\tPPSF\t\t\tHOAFEE\n\n");
for(int i=0;i<10;i++)
{
  
System.out.println(c[i].getAddress()+"\t"+c[i].getSF()+"\t"+c[i].getValue()+"\t"+c[i].getPPSF()+"\t"+c[i].getHOAfee());
}
}
}

Add a comment
Know the answer?
Add Answer to:
Write a complete Java program to do the following Your code should have: A super class...
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 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: 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) Methods...

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

  • Write the C# code and make a screenshot of the output according to tasks given below:...

    Write the C# code and make a screenshot of the output according to tasks given below: Create a class named Prism with protected data fields named height and volume (Use double data type for the fields) [5 points] Include public properties for each field. The Height and Volume properties should have get and set accessors. [5 points] Add default constructor which sets the value of Height and Volume properties to 1 and 1 respectively. [5 points] Add overloading constructor which...

  • Hello! This is C++. Q3. Write a program Define a Super class named Point containing: An...

    Hello! This is C++. Q3. Write a program Define a Super class named Point containing: An instance variable named x of type int. An instance variable named y of type int. Declare a method named toString() Returns a string representation of the point. Constructor that accepts values of all data members as arguments. Define a Sub class named Circle. A Circle object stores a radius (double) and inherit the (x, y) coordinates of its center from its super class Point....

  • In C++ Write a program that contains a class called VideoGame. The class should contain the...

    In C++ Write a program that contains a class called VideoGame. The class should contain the member variables: Name price rating Specifications: Dynamically allocate all member variables. Write get/set methods for all member variables. Write a constructor that takes three parameters and initializes the member variables. Write a destructor. Add code to the destructor. In addition to any other code you may put in the destructor you should also add a cout statement that will print the message “Destructor Called”....

  • Create a class named Module2. You should submit your source code file (Module2.java). The Module2 class...

    Create a class named Module2. You should submit your source code file (Module2.java). The Module2 class should contain the following data fields and methods (note that all data and methods are for objects unless specified as being for the entire class) Data fields: A String object named firstName A String object named middleName A String object name lastName Methods: A Module2 constructor method that accepts no parameters and initializes the data fields from 1) to empty Strings (e.g., firstName =...

  • 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 help me with this code. Thank you Implement the following Java class: Vehicle Class should...

    Please help me with this code. Thank you Implement the following Java class: Vehicle Class should contain next instance variables: Integer numberOfWheels; Double engineCapacity; Boolean isElectric, String manufacturer; Array of integers productionYears; Supply your class with: Default constructor (which sets all variables to their respective default values) Constructor which accepts all the variables All the appropriate getters and setters (you may skip comments for this methods. Also, make sure that for engineCapacity setter method you check first if the vehicle...

  • We have studied the following topics: How to interact with users via dialog boxes. Super class...

    We have studied the following topics: How to interact with users via dialog boxes. Super class and sub class. One- and two-dimensional arrays in Java. In this SLP assignment, we will make changes to our previous programs based on what we have learned. Write a Java application program to calculate property tax. Your program should have the following functions: Prompt users for the number of properties. Prompt users for property tax. Prompt users to input the value for each property...

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

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
ADVERTISEMENT