Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Secrets Of Analytical Leaders Insights From Information Insiders

Authors: Wayne Eckerson

1st Edition

1935504347, 9781935504344

More Books

Students also viewed these Databases questions

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago