Question

Design a class called Building. The class should keep the following information in the fields: String...

  1. Design a class called Building. The class should keep the following information in the fields:
  1. String address
  2. double property_value

create several constructors including copy constructor , create accessor and mutator methods

       Part 2 (50 points)

  1. Define interface Taxable which has one method getPropertyTax()

  1. Design a class called Private_Property that extends Building and implements Taxable

It should have the following field : double value_of_improvements

Create a constructor for this class to include newly added fields.

The tax for the private property should be calculated as

0.02* (property_value - value_of_improvements)

  1. Design a class called  Commercial_Property that extends Building and implements Taxable

It should have the following fields: double advertising_cost, double professional_expences

Create a constructor for this class.

The tax should be calculated as 0.02* (property_value - advertising_cost - professional_expences)

Part 3 (50 points)

  1. Create a Demo class. In the main method create two variables of type Taxable. One should be instantiated as Private_Property and another as Commercial_Property. Demonstrate polymorphic behavior of the method getPropertyTax()

What you need to submit:

  1. Complete code for all of the classes you created
  2. Word file with
    1. Screenshot of copy constructor from part 1
    2. Screenshot of implementation of getPropertyTax() for each of the classes
    3. Screenshot of main method from the demo class
    4. Screenshot of execution results
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note: Could you plz go through this code and let me know if u need any changes in this.Thank You
=================================

// Taxable.java

public interface Taxable {
double getPropertyTax();
}

=============================

// Building.java

public class Building {
private String address;
private double property_value;
   /**
   * @param address
   * @param property_value
   */
   public Building(String address, double property_value) {
       this.address = address;
       this.property_value = property_value;
   }
  
   public Building(Building b) {
       this.address = b.address;
       this.property_value = b.property_value;
   }
   /**
   * @return the address
   */
   public String getAddress() {
       return address;
   }
   /**
   * @param address the address to set
   */
   public void setAddress(String address) {
       this.address = address;
   }
   /**
   * @return the property_value
   */
   public double getProperty_value() {
       return property_value;
   }
   /**
   * @param property_value the property_value to set
   */
   public void setProperty_value(double property_value) {
       this.property_value = property_value;
   }

  
}


=================================

// Private_Property.java

public class Private_Property extends Building implements Taxable {
   private double value_of_improvements;

   /**
   * @param address
   * @param property_value
   * @param value_of_improvements
   */
   public Private_Property(String address, double property_value,
           double value_of_improvements) {
       super(address, property_value);
       this.value_of_improvements = value_of_improvements;
   }

   @Override
   public double getPropertyTax() {

       return 0.02 * (getProperty_value() - value_of_improvements);
   }

   /**
   * @return the value_of_improvements
   */
   public double getValue_of_improvements() {
       return value_of_improvements;
   }

   /**
   * @param value_of_improvements the value_of_improvements to set
   */
   public void setValue_of_improvements(double value_of_improvements) {
       this.value_of_improvements = value_of_improvements;
   }

  
}


===================================

// Commercial_Property.java

public class Commercial_Property extends Building implements Taxable {
private double advertising_cost;
private double professional_expences;


   /**
* @param address
* @param property_value
* @param advertising_cost
* @param professional_expences
*/
public Commercial_Property(String address, double property_value,
       double advertising_cost, double professional_expences) {
   super(address, property_value);
   this.advertising_cost = advertising_cost;
   this.professional_expences = professional_expences;
}


   /**
   * @return the advertising_cost
   */
   public double getAdvertising_cost() {
       return advertising_cost;
   }


   /**
   * @param advertising_cost the advertising_cost to set
   */
   public void setAdvertising_cost(double advertising_cost) {
       this.advertising_cost = advertising_cost;
   }


   /**
   * @return the professional_expences
   */
   public double getProfessional_expences() {
       return professional_expences;
   }


   /**
   * @param professional_expences the professional_expences to set
   */
   public void setProfessional_expences(double professional_expences) {
       this.professional_expences = professional_expences;
   }


   @Override
   public double getPropertyTax() {
       return 0.02* (getProperty_value() - advertising_cost - professional_expences);
   }

}

=======================================

// Demo.java

public class Demo {

   public static void main(String[] args) {

       double tax_Private_Property ,tax_Commercial_Property;
      
       Private_Property pp=new Private_Property("Park Street,Delhi",450000,34000);
       tax_Private_Property=pp.getPropertyTax();
       Commercial_Property cp=new Commercial_Property("Church Street,Banglore", 980000, 2500, 34000);
       tax_Commercial_Property=cp.getPropertyTax();
      
       System.out.println("Tax For Private Property :$"+tax_Private_Property);
       System.out.println("Tax For Commercial Property :$"+tax_Commercial_Property);
      
   }

}

=================================

output:

Tax For Private Property :$8320.0
Tax For Commercial Property :$18870.0

=====================Could you plz rate me well.Thank You

Add a comment
Know the answer?
Add Answer to:
Design a class called Building. The class should keep the following information in the fields: String...
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
  • JAVA HELP Design a class named Employee. The class should keep the following information in fields:...

    JAVA HELP Design a class named Employee. The class should keep the following information in fields: Employee name Employee number in the format XXX–L, where each X is a digit within the range 0–9 and the L is a letter within the range A–M. Hire date then, Write one or more constructors and the appropriate accessor and mutator methods for the class. Next, write a class named ProductionWorker that extends the Employee class. The ProductionWorker class should have fields to...

  • Design a class named Employee. The class should keep the following information in

    WRITE IN C++ ONLY PLEASE. IM USING VISUAL STUDIO CODE.1. Employee and ProductionWorker ClassesDesign a class named Employee. The class should keep the following information in• Employee name• Employee number• Hire dateWrite one or more constructors and the appropriate accessor and mutator functions for the class.Next, write a class named ProductionWorker that is derived from the Employee class. The ProductionWorker class should have member variables to hold the following information:• Shift (an integer)• Hourly pay rate (a double )The workday...

  • Language is JAVA. Clarification for the Shape class (highlighted): The following requirements specify what fields you...

    Language is JAVA. Clarification for the Shape class (highlighted): The following requirements specify what fields you are expected to implement in your Shape class; - A private String color that specifies the color of the shape - A private boolean filled that specifies whether the shape is filled - A private date (java.util.date) field dateCreated that specifies the date the shape was created Your Shape class will provide the following constructors; - A two-arg constructor that creates a shape with...

  • Design a class named Person with fields for holding a person's name, address, and telephone number...

    Design a class named Person with fields for holding a person's name, address, and telephone number (all as Strings). Write a constructor that initializes all of these values, and mutator and accessor methods for every field. Next, design a class named Customer, which inherits from the Person class. The Customer class should have a String field for the customer number and a boolean field indicating whether the customer wishes to be on a mailing list. Write a constructor that initializes...

  • Design a JAVA class called Course. The class should contain: ○ The data fields courseName (String),...

    Design a JAVA class called Course. The class should contain: ○ The data fields courseName (String), numberOfStudents (int) and courseLecturer (String). ○ A constructor that constructs a Course object with the specified courseName, numberOfStudents and courseLecturer. ○ The relevant get and set methods for the data fields. ○ A toString() method that formats that returns a string that represents a course object in the following format: (courseName, courseLecturer, numberOfStudents) ● Create a new ArrayList called courses1, add 5 courses to...

  • Code should be in C# Create a class called SavingsAccount.  Use a static variable called annualInterestRate to...

    Code should be in C# Create a class called SavingsAccount.  Use a static variable called annualInterestRate to store the annual interest rate for all account holders.  Each object of the class contains a private instance variable savingsBalance, indicating the amount the saver currently has on deposit. Provide method CalculateMonthlyInterest to calculate the monthly interest by multiplying the savingsBalance by annualInterestRate divided by 12 – this interest should be added to savingsBalance.  Provide static method setAnnualInterestRate to set the annualInterestRate to a new value....

  • Using JAVA* Design a class named Person with fields for holding a person’s name, address, and...

    Using JAVA* Design a class named Person with fields for holding a person’s name, address, and telephone number. Write one or more constructors and the appropriate mutator and accessor methods for the class’s fields. Next, design a class named Customer, which extends the Person class. The Customer class should have a field for a customer number and a boolean field indicating whether the customer wishes to be on a mailing list. Write one or more constructors and the appropriate mutator...

  • python Design a class named Car that has the following fields: yearModel: The yearModel field is...

    python Design a class named Car that has the following fields: yearModel: The yearModel field is an Integer that holds the car’s year model. make: The make field references a String that holds the make of the car. speed: The speed field is an Integer that holds the car’s current speed. In addition, the class should have the following constructor and other methods: Constructor: The constructor should accept the car’s year model and make as arguments. These values should be...

  • Programming Assignment 1 Write a class called Clock. Your class should have 3 instance variables, one...

    Programming Assignment 1 Write a class called Clock. Your class should have 3 instance variables, one for the hour, one for the minute and one for the second. Your class should have the following methods: A default constructor that takes no parameters (make sure this constructor assigns values to the instance variables) A constructor that takes 3 parameters, one for each instance variable A mutator method called setHour which takes a single integer parameter. This method sets the value of...

  • C++ Assignment: Create a class called FitnessMember that has only one variable, called name. The FitnessMember...

    C++ Assignment: Create a class called FitnessMember that has only one variable, called name. The FitnessMember class should have a constructor with no parameters, a constructor with a parameter, a mutator function and an accessor function. Also, include a function to display the name. Define a class called Athlete which is derived from FitnessMember. An Athlete record has the Athlete's name (defined in the FitnessMember class), ID number of type String and integer number of training days. Define a class...

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