Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Anyone can help me with this please please please !!! Implement a Java program that enables a shop owner to maintain the inventory of items

Anyone can help me with this please please please !!!

Implement a Java program that enables a shop owner to maintain the inventory of items sold as well as to sell items to customers. The inventory is kept as follows:

Orange 14 5.5

Apple 27 7.0

Banana 20 4.5

Guava 17 6.0

Mango 34 8.0

Papaya 16 10.0

Grapes 21 6.5

where it contains a unique item name, the stock of that item, and the unit price of the item in Saudi Riyals (SAR) respectively.

Your program must have the following main menu:

1. Display Stock Info for all Items

2. Display Stock Info for Particular Item

3. Update Stock Info for Particular Item

4. Add new Item

5. Delete Item

6. Sell items to Customer

7. Exit

Please select your choice:

Your program must loop as long as option 7 has not been selected and displays an appropriate error message if an invalid choice is entered. Each of the options 1 to 6 must be implemented in a separate static method. The sub-menu for option 3 and the code for Press Enter key to continue . . . must also be implemented is separate static methods.

The options must have the following behaviors:

Option 1: Display Stock Info for all Items

Displays the stock information of all items by reading from the database. It then waits for the Enter key to be pressed before returning control to the main menu:

Please select your choice: 1

Name Stock Quantity Unit Price(SAR)

Orange 14 5.50

Apple 27 7.00

Banana 20 4.50

Guava 17 6.00

Mango 34 8.00

Papaya 16 10.00

Grapes 21 6.50

Press Enter key to continue . . .

Option 2: Display Stock Info for Particular Item

Prompts for and reads the name of an item. It then searches this item in the inventory without case-sensitivity. If the item is not found, an appropriate error message is displayed, otherwise; the stock information for the item is displayed. In both cases, the option waits for the Enter key to be pressed before returning control to the main menu.

Please select your choice: 2

Enter fruit name: banana

Name Stock Quantity Unit Price(SAR)

Banana 20 4.50

Press Enter key to continue . . .

Please select your choice: 2

Enter fruit name: tangerine

Error: No such fruit

Press Enter key to continue . . .

Option 3: Update Stock Info for Particular Item

Prompts for and reads the name of the item whose stock is to be modified. Searches for the item, without case-sensitivity, in the inventory. If the item is not found, an error message is displayed, and after the Enter key is pressed, control is returned to the main menu. If the item is found, the following sub-menu is then displayed:

Please select your choice: 3

Enter fruit name: guava

1. Modify stock quantity

2. Modify unit price

Please select your choice:

Your program must then update the inventory according to the selected choice. However, if the stock quantity entered is negative or the unit price is less or equal to zero, display an appropriate error message:

Please select your choice: 3

Enter fruit name: guava

1. Modify stock quantity

2. Modify unit price

Please select your choice: 1

Available stock for Guava is 17

Enter new stock quantity: -2

Error: Negative stock quantity

Press Enter key to continue . . .

Please select your choice: 3

Enter fruit name: guava

1. Modify stock quantity

2. Modify unit price

Please select your choice: 1

Available stock for Guava is 17

Enter new stock quantity: 30

Stock quantity update for this item done

Press Enter key to continue . . .

Please select your choice: 3

Enter fruit name: banana

1. Modify stock quantity

2. Modify unit price

Please select your choice: 2

Current unit price for Banana is 4.50 SAR

Enter new unit price: 6.00

Unit price updated for this item

Press Enter key to continue . . .

Whether the update operation was done or not, control is returned to the main menu after pressing the Enter key.

Option 4. Add new Item

Please select your choice: 4

Enter fruit name:

If the fruit name already exists then give an error message. If the fruit name does not exist then enter the fruit name in it.

Enter stock quantity:

Enter unit price:

Option 5. Delete Item

Please select your choice: 5

Enter fruit name:

If the fruit name does not exist then give an error message. If the fruit name exists then empty its name and make its quantity and price as 0.

Option 6. Sell items to Customer

Sells one or more items to a customer if the requested item or items are available and if the requested amounts are less or equal to the associated stock quantities. Each time an item is sold the customer bill is displayed. If a quantity becomes 0 then remove the item from the database as in option 5.

EXAMPLE

Please select your choice: 6

Enter name of item: orange

Enter number of items required: 40

Insufficient stock. Stock available is 14

Do you want buy another item (Y/N): y

Enter name of item: orange

Enter number of items required: 10

Fruit Quantity Unit Price(SAR) Subtotal(SAR)

orange 10 5.50 55.00

Do you want buy another item (Y/N): y

Enter name of item: apple

Enter number of items required: 4

Fruit Quantity Unit Price(SAR) Subtotal(SAR)

apple 4 7.00 28.00

Do you want buy another item (Y/N): y

Enter name of item: apricot

Enter number of items required: 2

Error: Item not found

Do you want buy another item (Y/N): y

Enter name of item: guava

Enter number of items required: 2

Fruit Quantity Unit Price(SAR) Subtotal(SAR)

guava 2 6.00 12.00

Do you want buy another item (Y/N): n

Total: 95.00

Press Enter key to continue . . .

Control is returned to the main menu after pressing the Enter key.

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

Database Processing

Authors: David M. Kroenke, David Auer

11th Edition

B003Y7CIBU, 978-0132302678

More Books

Students also viewed these Databases questions

Question

How do Dimensional Database Models differ from Relational Models?

Answered: 1 week ago

Question

What type of processing do Relational Databases support?

Answered: 1 week ago

Question

Describe several aggregation operators.

Answered: 1 week ago