COMP2000 Assignment 6 solved

$35.00

Category: You will receive a download link of the .ZIP file upon Payment

Description

5/5 - (1 vote)

Write a program to maintain a hash table of “parts information” using “open addressing with double hashing”.
The data for each part consists of the following fields:
number string(max 6)
name string(max 20)
description string(max 30)
unit price double
quantity in stock integer
Strings are supplied in double quotes. One or more spaces separate consecutive data items.
Your program must:
(1) Load the file of parts information. Assume that one line contains information for one part. A line containing “$$$$$$” only ends the data. The parts must be linked in the hash table in ascending order by part number.
(2) The next portion of data consists of two or three values. The first value is a command (P, D, C or E). The second value is a part number.
If P, print the information for the part.
If D, delete the part provided that its quantity in stock is 0. Print a message if there is stock and ignore the command.
If C, the part number is followed by an integer (n, say); n is to be subtracted from the quantity in stock for that part provided the stock does not fall below 0. If subtracting n will cause the stock to fall below 0, print an appropriate message and ignore the command.
If E, this indicates the end of the data.
Commands can be supplied in upper or lower case and the part numbers are not enclosed in quotation marks.
(3) After the above, print the parts data in ascending order by part number by following the links in the hash table.
Some sample data

“K300” “Keyboard” “US Generic” 150.00 50
“R576” “16-inch Rims” “Toyota Verossa” 800.00 48
“HL412” “Headlight” “Ford Taurus 2010” 600.00 52
“E900” “Engine” “Hyundai Fuel Injected” 1200.00 8
“EM125” “Engine Mount” “Toyota Camry 2006” 300.00 12
“FL400” “Fog Lights” “Blue, Nissan Almera” 250.00 36
“$$$$$$”
P K300
d R576
C E900 6
c EM125 13
C FL400 15
e