Ask Question
19 October, 22:08

Create an abstract class Homeowner. Your Homeowner class should include the following attributes: First name (string) Last name (string) Homeowner home street address (string) Homeowner home city (string) Homeowner home state (string) Homeowner home county (string) Write a constructor to initialize the above Homeowner attributes. Create an abstract method called propertyTaxes.

+1
Answers (1)
  1. 20 October, 02:06
    0
    import java. util. Scanner;

    abstract class Homeowner

    {

    private String firstName, lastName, streetAddress, city, state, county;

    public Homeowner (String firstName, String lastName, String streetAddress, String city, String state, String county)

    {

    this. firstName = firstName;

    this. lastName = lastName;

    this. streetAddress = streetAddress;

    this. city = city;

    this. state = state;

    this. county = county;

    }

    public abstract double propertyTaxes ();

    }

    class countyNeighbor extends Homeowner

    {

    private double propertyValue, countyTaxRate;

    public countyNeighbor (String firstName, String lastName, String streetAddress, String city, String state, String county, double propertyValue, double countyTaxRate)

    {

    super (firstName, lastName, streetAddress, city, state, county);

    this. propertyValue = propertyValue;

    this. countyTaxRate = countyTaxRate;

    }

    public double propertyTaxes ()

    {

    return propertyValue * countyTaxRate;

    }

    }

    class Test

    {

    public static void main (String[] args)

    {

    Scanner input = new Scanner (System. in);

    System. out. println ("Enter firstName of the homeowner : ");

    String firstName = input. next ();

    System. out. println ("Enter lastName of the homeowner : ");

    String lastName = input. next ();

    System. out. println ("Enter streetAddress of the homeowner : ");

    String streetAddress = input. next ();

    System. out. println ("Enter city of the homeowner : ");

    String city = input. next ();

    System. out. println ("Enter state of the homeowner : ");

    String state = input. next ();

    System. out. println ("Enter county of the homeowner : ");

    String county = input. next ();

    System. out. println ("Enter propertyValue of the homeowner : ");

    double propertyValue = input. nextDouble ();

    System. out. println ("Enter countyTaxRate of the homeowner : ");

    double countyTaxRate = input. nextDouble ();

    countyNeighbor cn = new countyNeighbor (firstName, lastName, streetAddress, city, state, county, propertyValue, countyTaxRate);

    System. out. println ("Property Tax = $" + cn. propertyTaxes ());

    System. out. println ("Enter firstName of the homeowner : ");

    firstName = input. next ();

    System. out. println ("Enter lastName of the homeowner : ");

    lastName = input. next ();

    System. out. println ("Enter streetAddress of the homeowner : ");

    streetAddress = input. next ();

    System. out. println ("Enter city of the homeowner : ");

    city = input. next ();

    System. out. println ("Enter state of the homeowner : ");

    state = input. next ();

    System. out. println ("Enter county of the homeowner : ");

    county = input. next ();

    System. out. println ("Enter propertyValue of the homeowner : ");

    propertyValue = input. nextDouble ();

    System. out. println ("Enter countyTaxRate of the homeowner : ");

    countyTaxRate = input. nextDouble ();

    countyNeighbor cn1 = new countyNeighbor (firstName, lastName, streetAddress, city, state, county, propertyValue, countyTaxRate);

    System. out. println ("Property Tax = $" + cn1. propertyTaxes ());

    }

    }

    Output:

    Enter firstName of the homeowner : John

    Enter lastName of the homeowner : Smith

    Enter streetAddress of the homeowner : 345, downstreet

    Enter city of the homeowner : NY

    Enter state of the homeowner : NY

    Enter county of the homeowner : Albany

    Enter propertyValue of the homeowner : 56788.00

    Enter countyTaxRate of the homeowner : 0.07

    Property Tax = $3975.1600000000003

    Enter firstName of the homeowner : Cathy

    Enter lastName of the homeowner : Jones

    Enter streetAddress of the homeowner : 456, lane-2

    Enter city of the homeowner : NY

    Enter state of the homeowner : NY

    Enter county of the homeowner : Bronx

    Enter propertyValue of the homeowner : 36762.00

    Enter countyTaxRate of the homeowner : 0.08

    Property Tax = $2940.96
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Create an abstract class Homeowner. Your Homeowner class should include the following attributes: First name (string) Last name (string) ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers