Question

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 methods Create 50 Condo objects in an array (use a loop) The addresses are 101 thru 110 Hardscrabble Drive The SF are between 850-1250. Randomly assign this Use the calcValue() method to fill the values The HOAfees are all $350 After you have filled the array, output the contents of the array to the console. Create a Main() method to execute your logic. Don’t be too concerned with minor syntax errors. Draw a line in your code (---------------------) to separate your classes Home() Condo() and Main()

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program Code Screenshot :

1 2 import java.util. Random; // Home class 3 of class Home{ //Instance variables 5 String address; double SF; 7 double value

46 47 48 //Condo class class Condo extends Home{ //Instance variables double HoAfee; 49 59 51 52 53 //Getter and Setter publi

Sample Output :

Run: + Main X C:\Program Files\Java\jdk-13\bin\java.exe Address : 101 thru 110 Hardscrabble Drive SF : 1034.0 Value : 41360

Program Code to Copy

import java.util.Random;
//Home class
class Home{
    //Instance variables
    String address;
    double SF;
    double value;

    //Getter and Setter
    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public double getSF() {
        return SF;
    }

    public void setSF(double SF) {
        this.SF = SF;
    }

    public double getValue() {
        return value;
    }

    public void setValue(double value) {
        this.value = value;
    }

    //Calculate value method
    void calcValue(){
        value = SF*400;
    }

    //Method to display condo
    void displayCondo(){
        System.out.println("Address : "+address);
        System.out.println("SF : "+SF);
        System.out.println("Value : "+value);
    }
}

//Condo class
class Condo extends Home{
    //Instance variables
    double HOAfee;

    //Getter and Setter
    public double getHOAfee() {
        return HOAfee;
    }

    public void setHOAfee(double HOAfee) {
        this.HOAfee = HOAfee;
    }
}

class Main{
    public static void main(String[] args) {
        Random r = new Random();
        Condo condo[] = new Condo[50];
        for(int i=0;i<condo.length;i++){
            condo[i] = new Condo();
            condo[i].setAddress("101 thru 110 Hardscrabble Drive");
            condo[i].SF = 850+r.nextInt(401);
            condo[i].calcValue();
            condo[i].HOAfee = 350;
        }
        for(int i=0;i<condo.length;i++){
            condo[i].displayCondo();
        }
    }
}
Add a comment
Know the answer?
Add Answer to:
Code a Java program to create and use OO classes. Comment your code throughout. Create a...
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...

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

  • Java file Name Dog Classes and Methods Create a constructor that incorporates the type, breed, and...

    Java file Name Dog Classes and Methods Create a constructor that incorporates the type, breed, and name variables (do not include topTrick). Note: The type refers to what the breed typically does; for example, a corgi would be a “cattle herding dog.” A Shiba Inu would be a “hunting dog.” Create the setTopTrick() mutator method Dog is parent class Corgi and Driver are subclasses Complete the Corgi class: Using the UML Class diagram, declare the instance variables. Create the two...

  • JAVA Problem:  Coffee do not use ArrayList or Case Design and implement a program that manages coffees....

    JAVA Problem:  Coffee do not use ArrayList or Case Design and implement a program that manages coffees. First, implement an abstract class named Coffee. The Coffee class has three member variables: coffee type, price, and store name. The Coffee class has an abstract method name ingredient. Make sure to add all necessary setters and getters as well as other methods. The class Coffee implements an interface HowToMakeDrink. The interface has the following method: public interface HowToMakeDrink { public void prepare ();...

  • Write a C++ program for the instructions below. Please read the instructions carefully and make sure they are followed correctly.   please put comment with code! and please do not just copy other solu...

    Write a C++ program for the instructions below. Please read the instructions carefully and make sure they are followed correctly.   please put comment with code! and please do not just copy other solutions. Instructions 1. Read instructions carefully! 2. Use C++ syntax only, C syntax will not be accepted. 3. Always use braces to define blocks. 4. Indent all lines within a block. Each block requires one more tab. 5. Organize your code well with proper formatting and a single...

  • Computer Science 111 Introduction to Algorithms and Programming: Java Programming Net Beans Project #4 - Classes...

    Computer Science 111 Introduction to Algorithms and Programming: Java Programming Net Beans Project #4 - Classes and Objects (15 Points) You will create 3 new classes for this project, two will be chosen (THE TWO CHOSEN ARE TENNIS SHOE AND TREE) from the list below and one will be an entirely new class you invent. Here is the list: Cellphone Clothes JuiceDrink Book MusicBand Bike GameConsole Tree Automobile Baseball MusicPlayer Laptop TennisShoe Cartoon EnergyDrink TabletComputer RealityShow HalloweenCostume Design First Create...

  • JAVA HELP (ARRAYS) Assignment Create a class named Module4 containing the following data members and methods...

    JAVA HELP (ARRAYS) Assignment Create a class named Module4 containing the following data members and methods (note that all data members and methods are for objects unless specified as being for the entire class) 1) Data members: none 2) Methods a. A method named displayContents that accepts an array of type int and prints their values to the b. A method named cemoveNegatives that accepts an array of type int, copies all its non-negative the new array should be the...

  • in java : Create Java Application you are to create a project using our designated IDE...

    in java : Create Java Application you are to create a project using our designated IDE (which you must download to your laptop). Create the code to fulfill the requirements below. Demonstrate as stipulated below. Create a Main Application Class called AddressBookApplication (a counsole application / command line application). It should Contain a Class called Menu that contains the following methods which print out to standard output a corresponding prompt asking for related information which will be used to update...

  • Java — write code to represent the following classes in the order asked. Use comparable —>compateTo(),...

    Java — write code to represent the following classes in the order asked. Use comparable —>compateTo(), toString() and create a constrcutor. Follow the question outline please 62. 6S points) Writehfl Jaoe for a clss below that represents an aple where the following things Apples have a weight and a brand and cannot be created without these. are important to represent: Apples havs-natural ordering by weight, brand is not important). When an apple is printed, it should display all the properties...

  • JAVA Problem:  Coffee    Design and implement a program that manages coffees. First, implement an abstract class...

    JAVA Problem:  Coffee    Design and implement a program that manages coffees. First, implement an abstract class named Coffee. The Coffee class has three member variables: coffee type, price, and store name. The Coffee class has an abstract method name ingredient. Make sure to add all necessary setters and getters as well as other methods. The class Coffee implements an interface HowToMakeDrink. The interface has the following method: public interface HowToMakeDrink { public void prepare (); } The prepare method will...

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