Assume that you are developing a billing software for a departmental store which sells electronic appliances, clothing, and toys. The store offers discounts on a festival occasion as below:
a) 20 % discount on electronic appliances whose prices are greater than or equal to $100
b) 30 % discount on clothing if the price of a clothing item is greater than or equal to $50
c) All the toys greater than or equal to $20 are subject to 10% discount.
All goods except toys are taxed at 8.5% of its price.
1. Define a Base class Item with the following fields:
i. item code (int)
ii. item name (String)
2. Define Subclasses called Electronics, Clothing and Toys with the following fields:
I. quantity (int)
II. price (double)

Create an interface called Discount with a method declaration called void computeDiscount() and another interface called Tax with a method declaration called computeTax().

Create a demo class called DemoInterfaces with a main method and create objects for each of the subclass and print the following:
Item name
Item quantity
Item Price
final price after discount and tax

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

public class Clothing extends Base implements Discount, Tax {

private int quantity;
private double price;
private double discount;
private double tax;

public Clothing(int ic, String nm, int q, double p) {
super(ic, nm);
quantity = q;
price = p;

public int getQuantity() {
return quantity;

public double getPrice() {
return price;

public void setQuantity(int qn) {
quantity = qn;

public void setPrice(double pr) {
price = pr;

public void computeDiscount() {
if(price >= 50)
discount = price * 0.3;

public double getDiscount() {
return discount;
$18.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats