Write a program that uses a hashing algorithm to create a list of inventory parts and their quantities sold in the past month. After creating the hashed list, write a simple menu-driven user interface that allows the user to select from the following options:
a. Search for an inventory item and report its quantity sold
b. Print the inventory parts and their quantities sold
c. Analyze the efficiency of the hashing algorithm
The parts data are contained in a text file, as shown in Table 13-4. The key is the three-digit part number. The quantity represents the units sold during the past month.
Part Number
|
Quantity
|
112
|
12
|
130
|
30
|
156
|
56
|
173
|
17
|
197
|
19
|
150
|
50
|
166
|
66
|
113
|
13
|
123
|
12
|
143
|
14
|
167
|
16
|
189
|
18
|
193
|
19
|
117
|
11
|
176
|
76
|
Table: Data for hashing program
Three outputs are required from your program.
a. Test the following searches and return appropriate messages. You may test other part numbers if you desire, but the following tests must be completed first:
? Search for 112
? Search for 126
? Search for 173
b. When requested, analyze the efficiency of the hashing algorithm for this set of data. Your printout should follow the report format shown below.
c. The printout of the entire contents of the list should use the following format: