Question: Need this in java coding. Implement a printer queue to simulate printing of documents. Use a linked implementation of queue data structure. Each node contains

Need this in java coding. Implement a printer queue to simulate printing of documents. Use a linked implementation of queue data structure. Each node contains two pieces of information: document ID and printing time. The documents arrive every 5 time units and are assigned printing times chosen at random in the interval (1,8). As the documents arrive, they are added at the rear end of the queue. The document at the front of the queue is removed and is assigned to the printer. Display the details (document ID, printing time) of the document when they arrive at the queue and when the printing is finished. The printer can print only one document at a time. Run the simulation for 50 time units.

Remove documents from Queue, display printing status Modify PrinterQueue.java to accomplish the following steps during the simulation period (i.e. the code for the following steps will need to be added to the for loop that represents the simulation period of 50 seconds) If the queue is not empty and the printer is free (not busy), perform the following operations: o remove (dequeue operation) the document from queue. o Use a counter t to store the printing time of the document. o Display a message indicating that the printer has started printing the document with certain ID. Display the printing time of the document. o Display the current time. o Set the status of the printer to busy (you can use a boolean variable busy and set it to true) If the printer is busy, perform the following operations: o Decrement the counter t by 1 (to simulate the fact that 1 second has elapsed) o If t is 0 ( it indicates that the printing is finished), perform the following steps. Display a message indicating that the printer has finished printing the document with certain ID. Display the current time. Set the status of the printer to free (set the boolean variable busy to false)

Need this in java coding. Implement a printer queue to simulate printingof documents. Use a linked implementation of queue data structure. Each node

Sample Output During the Printer Queue Simulation Note: Your output may vary as the printing time is selected randomly docID: 10 Enqueued CurrentTime:0 Queue: (10,5) Started printing, docID: 10 PrintTime:5 Current Time:0 docID: 11 Enqueued CurrentTime:5 Queue: (11,6) Printing Finished, docID:10 Current Time:5 Started printing, docID: 11 PrintTime:6 Current Time:5 docID: 12 Enqueued CurrentTime 10 Queue: (12, 6) Printing Finished, docID:11 Current Time 11 Started printing, doCID: 12 PrintTime:6 Current Time:11 docID: 13 Enqueued CurrentTime: 15 Queue: (13, 3) Printing Finished, docID:12 Current Time 17 Started printing, docID: 13 PrintTime:3 Current Time: 17 docID: 14 Enqueued CurrentTime: 20 Queue: (14, 8) Printing Finished, docID: 13 Current Time:20 Started printing, docID: 14 PrintTime:8 Current Time:20 docID: 15 Enqueued CurrentTime:25 Queue: (15,4) Printing Finished, doCID:14 Current Time:28 Started printing, docID: 15 PrintTime:4 Current Time:28 docID: 16 Enqueued CurrentTime:30 Queue: (16,9 Printing Finished, docID:15 Current Time:32 Started printing, docID:16 PrintTime:9 Current Time: 32 docID: 17 Enqueued CurrentTime:35 Queue: (17,1) docID: 18 Enqueued CurrentTime:40 Queue: (17,1) (18, 9)

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!