Question: This question is of course ''Data Structure and Algorithms''. Solve the question below given in the picture. Write the code for the problem in java

This question is of course ''Data Structure and Algorithms''. Solve the question below given in the picture. Write the code for the problem in java language.

This question is of course ''Data Structure and Algorithms''. Solve the question

below given in the picture. Write the code for the problem in

Do the work according to the detail given in the pictures.

Question 1 [5+10+5+5+15) Suppose you are designing a system for a grocery store where number of categories in the system is pre- defined and known but the number of products is completely unknown. For example Category Items Juices Pid Pname Price Quantity 101 Rani Juice 80 200 102 Tropicana 100 300 103 Sugarcane juice 40 100 104 Wheatgrass 150 250 2/4 juice 105 Grapefruit juice 160 450 Soft Pid Pname Price Quantity Drinks 201 Coca Cola 100 1000 202 Pepsi 90 1500 203 Marinda 90 500 204 Shezan 500 500 205 Sprite 90 1500 Furniture Pid Pname Price Quantity 301 Couch 150000 5 302 Bureau 800000 2 303 Wardrobe 15000 3 304 Trundle Bed 500000 1 305 Hope Chest 1500 3 Chocolat Pid Pname Price Quantity 401 Dairy Milk 450 10 Twix 80 50 403 Sneakers 80 50 404 Mars 80 100 405 Galaxy 70 20 es 402 As you know there is a limited number of Categories but number of products against each category is completely different so we need a better data structure for this problem. So, Mr. Alex has a data structure but doesn't know programming so you have to help him to code his idea. Mr. Alex says as we have limited categories and we know the number of categories so we will create an Array of size (number of Categories) and in each index of an array there will be a Linked list which will increase dynamically and will be used to store the products against each category. To Implement Mr. Alex's idea, You have to do things listed below 1. Complete the implementation of given class below interface Comparator Sort the Products with Quantity Product - id: int -name: String - price: double - quantity : int - product Type: int + Constructors + Getters + Setters + toString 3/4 2. Open the file "input.txt" and see the format of text we have product information in the file like 101, Rani Juice, 80, 200, 1 201, Coco Cola, 100, 1000, 2 301, Couch, 15000, 5, 3 401, Dairy Milk, 450, 5, 4 The last number shows the product type 1 for Juices, 2 for Soft Drinks, 3 for Furniture and 4 for Chocolates. 3. Create a new file called DataLoader.java and in this class implement the method given below public AList loadData() This method will simply load the data from files and store them in the ArrayList (improted from java.util.*) we've created in the class. You have to load data from file and then create Product Objects and then finally store them in ArrayList and return the ArrayList when you are done with reading the file data. 4. Create a new file called Main.java and do things listed below a) Create a new ArrayList and then call the loadData method from DataLoader class to load the data from file. b) Sort the ArrayList using Collections. sort() method. c) Create 4 Linked Lists from the given code of AList of type Products and name them as Juices, Soft Drinks, Furniture and Chocolates d) Now traverse through all the products in ArrayList and store them into respective Alist, like the product with product Type 1 will be stored in AList of Juices and product with product Type 2 will be stored in AList of Drinks etc. e) Finally print all the AList you've created so far

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!