CMSC 206: Data Structures
Assignment#5
Due on Thursday, November 9, 2017
Simulating Printer Usage
A Computer Lab has a monochrome printer that prints 10 pages per minute. In any given hour there are 10 students working on their assignments. Each student prints something on the printer upto twice in an hour. Each print job could be anywhere from 1 to 20 pages long. That is, there are, on average, 20 print jobs in an hour. Do a simulation (as described in class) to determine, in an hour, what the average wait time for a student to wait for their print jobs to be finished. Based on the results, answer the following:
1. Is the wait time reasonable? (What is reasonable? You decide.)
2. What would be the average wait time if the printer were replaced by a new color printer. However, it prints at 5 pages per minute.
Technical Hints:
As designed in class, you will need the following two classes: Task, and Printer. Use the code priovided. The skeletal main program is also provided here. Also, the main simulation algorithm is described below:
simulate(seconds, ppm) : Perform the simulation for given time (seconds) for a printer that prints at speed (ppm) - Create a new printer at speed ppm
- Create a new printerQueue (a queue of Tasks)
- Create an array to record wait times
- for each tick (second)
- if there is a new task (see function newTask())
- create a new task and add it to the printerQueue
- if printer is not busy the printerQueue is not empty
- remove next task from printerQueue
- record wait time for this task
- start the next task on the printer
- printer prints for 1 second - compute average wait time & print results
What to Hand-in: