Question: You need to write a set of four Java classes. The structures for these Java classes are described here: A parent class of businesses (Business)

You need to write a set of four Java classes. The structures for these Java classes are described here:

A parent class of businesses (Business)

o This is an abstract class, so this class will have no concrete instance.

o All instance variables must be private. This class needs to keep track of at least four (4) pieces of information:

account number an integer (int)

business name a string (String)

the primary income a floating point value (double)

the secondary income a floating point value (double)

o This class must have the following API:

public Business (int accountNumber, String name); // this is the constructor, it creates and registers a business

public int getAccountNumber (); // return the account number of the business

public void setAccountNumber (int accountNumber); // set the account number of the business

public String getName (); // return the name of the business

public void setName (String name); // set the name of the business

public double getPrimaryIncome (); // return the accumulated primary income

public double getSecondaryIncome (); // return the accumulated secondary income

public void addPrimaryIncome (double amount); // add the amount to the accumulated primary income

public void addSecondaryIncome (double amount); // add the amount to the accumulated secondary income

public abstract double getTaxDue (); // abstract method for calculating tax (this method needs to be abstract since every type of business has a different tax calculating scheme)

public String report (); // return a string that lists the income and tax due (see below for details)

public static Business [] getRegisteredBusinesses (); // return an array of (registered) businesses1 , return an empty array (array of length zero) if no business has been registered yet

public static Business findBusiness (int accountNumber); // find (registered) business by account number, return null if none found

o Each type of businesses will have two types of incomes primary income and secondary income. Each of the primary income and secondary income are defined based on the type of business.

o The report () method must return a string that looks like the following (see example output files provided):

The first line shows the account number and name of business

The second line reports the type of this business

The third and the fourth lines display the primary and secondary income, respectively

The fifth line displays the total income

The sixth line shows the calculated tax due.

All floating point values (incomes and taxes due) should be output with two (2) digits after the decimal points. (Hint: use the format method of the String class. See API for details)

Three subclasses, one each for restaurants, hotels, and convenience stores.

o These subclasses cannot have instance variables private static constants are ok.

o These subclasses should have a constructor that takes an account number and a name.

o These subclasses should also implement the getTaxDue () and the report () methods to make the subclasses concrete.

The tax due for a restaurant is calculated as follow:

o Primary income is the (non-alcoholic) food income and will be charged a tax of 6%.

o Secondary income is the alcoholic income and will be charged a tax of 12%.

o If the secondary income is greater than primary income, a surtax of 5% will be charged. This surtax is calculated on the total income.

The tax due for a hotel is calculated as follow:

o Primary income is for room income.

o Secondary income is for suite income.

o The larger of the two types of income will be charged a tax of 15%, while the smaller one will be charged a tax of 12%.

The tax due for a convenience store is calculated as follow:

o Primary income is income for everything except newspaper and will be charged a tax of 7%.

o Secondary income is income for newspaper and will not be charged of any tax.

All methods, except for those defined in the API described above, must be private.

There cannot be any import statement in your file, except for the following (which is necessary for using the ArrayList class): import java.util.ArrayList;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!