CS14 - At-Home Programming Assignment 2

Project due Sunday, February 8 at 8:00 pm


UPDATED - Monday, Feb 2 at 9:30 pm
UPDATED - Tuesday, Jan 27 at 10:50 pm


Write a program that takes care of a printer queue. Your program will simulate and evaluate the printing. The arrival pattern of print jobs will be represented in a file as the arrival times (in printing time intervals (you can think fo these as some number of seconds or a minute)) of each print job and its number of pages. The file will be specified in a command line parameter to your program. Your program will take no input other than the test file name as the command line parameter. You will simply open the file, process the print jobs, print out the results, and exit. You may assume that the arrival times in the file are in order. It takes one time interval to print each page. You should process the jobs in the file and then print out the total number of jobs processed, the total number of pages printed, and the average waiting time per job. Waiting time is the number of intervals from arrival time to beginning of printing. The job at the head of the queue is currently being printed and is not dequeued until printing completion. Use a linked list to implement your queue. There are many List templates available (for example, the Standard Template Library offers a list template). However, for this assignment, when you use a linked list, it will be your own code so that you can practice your programming and learn the concepts thoroughly.

NOTE - Be aware of the precision of the average waiting time per job. You must print the average waiting time with a precision of 4 significant digits.

A sample file is shown below (a 0 specifies the end of the processing):

1 4
3 3
8 1
8 2
12 10
19 1
20 2
26 5
26 1
0

You can download the sample file here.

An explanation of the processing of the above file is shown below:

arrival time pages intervals used for printing number of waiting intervals
1 4 1 2 3 4 no wait
3 3 5 6 7 2
8 1 8 no wait
8 2 9 10 1
12 10 12 13 14 15 16 17 18 19 20 21 no wait
19 1 22 3
20 2 23 24 3
26 5 26 27 28 29 30 no wait
26 1 31 5

# of jobs # of pages   average waiting time per job
9 29   1.556

The output should look like this.

Notes on grading

Much of the grading of your program will be based on not just getting code to do the necessary functions correctly, but on your actual coding. Be sure to use good programming where possible (use of classes, functions, good parameter passing techniques, error checking, encapsulation, object oriented programming). Make sure your program is user friendly.

You must use a makefile to compile your program and you must at least use the compilation flags -W -Wall -Werror -pedantic. Programs will be graded under linux on hill.cs.ucr.edu. Significant points will be taken off if your program does not compile with a makefile or if you code under Windows.

Suggestions to follow while coding

What to turn in

You should have turned in what you have thus far on our program at least 6 hours before the due date (by 2pm). Then continue to work on your program and turn in more current versions as you get them working. Ideally, you should have your project done well before the due date.

You must turn in all .cc and .h files and your makefile. In addition, you must follow any guidelines and include any information that is stated on the main page about at-home programming assignments.

A reminder about collaboration on home programming assignments

Please remember, at-home programming assignments are not lab assignments and you may not team-code with your lab partner or any other individual. Limited collaboration may be acceptable, but programs must represent YOUR OWN original work. Sharing code or team-coding are strictly not allowed. Copying code from ANY source (any book, current or past students, past solutions, web, etc) is strictly not allowed even with citation. Collaboration may consist of discussing the general approach to solving the problem, but should not involve communicating in code or even pseudo-code. Students may help others find bugs. Your code MUST be unique -- the odds of randomly producing similar code is very low. Computing, like surgery or driving a car or playing golf, can only be learned by doing it yourself!