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.
Item number : String
Number of items sold : int
purchase price : double
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
For each item, an instance of the class Item is created and the profit (or loss) is calculated.
-
Write each instance created to an output file, "Items.out" using a PrintWriter Java class. Write
the profit or loss beside each item.
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started