Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Java: Write a program to manage an inventory. Create a Product class Each product in the inventory contains a product name, an amount in

Using Java:

Write a program to manage an inventory. Create a Product class Each product in the inventory contains a product name, an amount in stock, and a unit price. Provide default and parameterized constructors, accessor, and modifier functions.

Input:

The data should be read from a file and stored in an array of Product. Assume product names do not contain blanks. Size the initial array to 50 elements; code may assume no more than 50 products will be inserted as the program runs. File inventory.txt on Blackboard contains the initial data.

inventory.txt:

Mop 15 5.99 Pail 10 3.99 Hammer 1 7.99 Wrench 15 6.99 Pen 50 0.99 Pad 10 3.99 Calendar 0 2.99

This program will study the unordered array algorithms of sequential search, insert, and remove.

Processing: Use a loop to present a simple menu of choices to the user.

a) Edit the amount in stock of a product. If the item is found, report the name and the new amount in stock. If it is not found, report the name and a message that the item was not found.

b) Insert a new product with initial amount of stock and unit price. Report the name with a message it was successfully inserted. If the name already exists, report the name and a message that the item could not be inserted.

c) Remove a product. If the removal is successful, report the name and a message that the item was successfully removed. If the item is not found in the array, report the name and a message that the item could not be removed.

d) Display the inventory, listing each products name, number in stock, and unit price on separate lines using field widths to create a neat table. Under the table display the total worth of the inventory, computed as the sum of each products amount in stock times its unit price.

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 Marketing The New Profit Frontier

Authors: Ed Burnett

1st Edition

0964535629, 978-0964535626

Students also viewed these Databases questions