For this assignment you will create a program to support a small hardware store. Your program will be able to keep track of items in the inventory of the store, so that the owner knows the quantities of each item in stock.

To represent an item in your program, create a class named Item with the following fields:

  • ID number (random string of length 5 - can contain letters and numbers)
  • Name (string)
  • Category (string) - can only be one of the following: "Door&Window", Cabinet& Furniture, Fasteners, Structural, Other.
  • Quantity (integer)
  • Price (floating point number)

Your program should provide the user (store owner) with a command line choice menu about possible actions that they can perform. The choices should be the following:

  • Show all existing items in stock and their quantities.
  • Add a new quantity of a specific item to the stock.
  • Remove a certain quantity of a specific item type.
  • Search for an item (given its name or part of its name).
  • Show a list of all items below a certain quantity.
  • Exit program.

When the program first loads, it reads all the saved records (if any) from a file named database.txt into an ArrayList, and offers user 6 choices (listed on previous page).

The format of the contents of the database.txt file should be in human readable plain text, one record per line (note the ~ separator between different entries), e.g. While the program is running, the user can choose any of the 6 available options.

632VR~Nuts 1/2in~Fasteners~70~0.50
H43SM~Knobs 1-1/4in~Cabinet&Furniture~200~2.99
83RS9~Kwikset SmartLock~Door&Window~30~199.00

Selection options 2 or 3 changesArrayList not database.txt .

  • The database.txt file will be updated automatically the program first saves all the contents of the ArrayList into database.txt file, replacing old files, and then exits.

Selecting no 6 (exit) replaces entries in database.txt with new entries from ArrayList before exiting.

When the program first loads, it reads all the saved records (if any) from a file named database.txt into an ArrayList, and offers user 6 choices (listed on previous page). Selecting no 6 (exit) replaces entries in database.txt with new entries from ArrayList before exiting. The format of the contents of the database.txt file should be in human readable plain text, one record per line (note the ~ separator between different entries), e.g.

632VR~Nuts 1/2in~Fasteners~70~0.50
H43SM~Knobs 1-1/4in~Cabinet&Furniture~200~2.99
83RS9~Kwikset SmartLock~Door&Window~30~199.00

When displaying the items, print headers and format the data to line up in columns under the headers.

ID # Name; Category Quantity Price
632VR Nuts 1/2in Fasteners 70 0.50
H43SM Knobs 1-1/14in Cabinet and Furniture 200 2.99
83RS9 Kwikset Smartlock Door and Window 30 199.00

Price should be output showing two decimal digits: (e.g 99.95).

Be sure to validate the user input.

You don't need to create any GUI for this assignment. Command line operations are enough.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.