W comparator class that compares products by price


The HashMap inventory has already been declared, where Product has key attribute barcode which is of type String. The method getbarcode() is in Product. The variable p has already been declared and all attributes have already been entered.

1. Write the java code to insert p into inventory.

2. Prompt the user for a barcode and retrieve the product from the hashMap inventory.

3. Write a piece of code that prints out the names and barcodes of the objects in inventory.

4. Write a comparator class that compares Products by price.

5. Declare a priority queue that uses the comparator class in number 3 to compare Products.

Solution Preview :

Prepared by a verified Expert
JAVA Programming: W comparator class that compares products by price
Reference No:- TGS01412505

Now Priced at $30 (50% Discount)

Recommended (93%)

Rated (4.5/5)