Question: Java!!! Write a program named Lab 2 7 B . a . Create a secondary class named Gadget. It should have the following: i .
Java!!!
Write a program named LabB
a Create a secondary class named Gadget. It should have the following:
i Two instance variables: the gadget ID int and the gadget name String
ii A constructor that receives an int and a String parameter and fills in both
instance variables.
iii. An int method to return the gadget ID
iv A toString method to return a string with the instance variables.
b In your main class do the following:
i Write an int method that receives an int parameter the gadget ID and returns
the result of performing the hash function on the parameter.
The hash function will be key
ii In the main method:
Create an array of Gadget objects.
Read the gadget IDs and names in from the text file InputBtxtYou
don't know how many customers there will be but it will be For
each one:
a Calculate the hash code by sending the gadget ID to your
hashing function method.
b Write the gadget's name and hash function result
c Create a Gadget object
d Add the object to your hash table array at the index returned by
your hash function method. If there is a collision, use the
quadratic probing method to find an empty one. Place the
object there.
If you get to the end of the array, go back up to index again.
After all customers have been added to the hash table, print the hash
table array. Dont print the nulls, though. Print the index number
before each gadget object's info.
Youll probably need to write a for loop for this instead of using
Arrays.toString.
InputFile
Bookend
Can opener
Microwave
Clock
Refrigerator
Ice maker
Radio
Counter top range
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
