Search for question
Question

2. Use the STL queue (std:queue) container to implement a print queue that accepts incoming print jobs, named as PrintJob #1, PrintJob #2, etc. The print jobs arrive in random order in the sense that the first job might be PrintJob #4, the next one might be Printjob #1, etc. The print queue will look something like this:

PrintJob #4 PrintJob #2 PrintJob #1 PrintJob #3 ..

The program will generate the print job name strings (the digits are random numbers) and inserts these into the queue in the order received. After every second job inserted in the queue, the program will pop the job at the front of the queue displaying a message saying a particular job, identified by its name, is completed and the size of the queue.

As each job is inserted in the queue, the program will display a message saying “Added PrintJob #n to the queue. Size of the queue is …”.

Insert a total about 10 jobs to the queue. Please remember that the actions of adding jobs to the queue and every so often removing the job at the front of the queue should be interspersed.

Submit the code and the output on Camvas.