Question: Problem 2 1. A supermarket is selling some items. It needs to know the profit it is making after selling each day. Help the supermarket

Problem 2

1. A supermarket is selling some items. It needs to know the profit it is making after selling each day. Help the supermarket owner by building an application to do that.

Create a class named Item which has the following fields.

  1. Item number : String

  2. Number of items sold : int

  3. purchase price : double

  4. selling Price : double

2. Write two constructors for the class Item: one without parameters, and another with parameters to fill all its attributes.

3. Write an accessor and a mutator method for each attribute. Make all methods public. 4. Write a toString() method to display the attributes of the class Item

Testing:

1. Write a Java program TestSupermarket. In the main method, open the file ItemInventory.txt and read the information about each item:

ABC1234 20 35.5 40.5

XYZ5434 30 200 230

WQE767 250 100 90

TRY1290 100 25 30

  1. For each item, an instance of the class Item is created and the profit (or loss) is calculated.

  2. Write each instance created to an output file, "Items.out" using a PrintWriter Java class. Write

    the profit or loss beside each item.

  3. At the end, write the total profit or loss for the supermarket on this day.

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!