CS14 - At-Home Programming Assignment 2



Test files used

You may download the following test files to determine how well your project did. These are the test files used to grade your assignments.


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. 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. HINT - use iomanip

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

Your output MUST match mine EXACTLY. This is my output. You need to determine if yours is exactly like mine by using the diff command. Do a man on diff for more information (type "man diff" at the command prompt). Basically, you need to run the following command in Linux: "diff --ignore-all-space --ignore-blank-lines youroutput.out myoutput.out" and if the files are the same, nothing will be printed to the screen (That is your goal). To capture your output to a file, you can use the output redirection available in the Linux shell. You can redirect your output using > . To capture your output for this project, your command would look similar to this: "printqueue inputfile.txt > youroutput.out" where printqueue might be the name of your executable, inputfile.txt might be the name of the input file you are using, and youroutput.out is what normally would have been printed to the screen.

Format of input file

Don't make any assumptions on the correctness of the input file. I gave you a sample of what the input file would look like, and if the input file is in the correct format, that is exactly what it will look like. However, you should never make any assumptions about the correctness of the input file. I will make other test files with invalid input cases and I will expect that you code will never crash. If, while reading in the file, you find something that does not match the expected input format, print out an error message and exit the program. Examples

Format of output

To make sure that your output file matches mine exactly, I will list the special things you must know: However, we will be ignoring blank lines and white space so it is really not that important to get it looking EXACTLY the same with respect to white space. It should just look similar.

Object Oriented Programming for the print queue

There is a lot of freedom in the design of this assignment and since writing the actual queue code is simple (I give a lot of it in class), a large portion of the points will be dedicated to your OOP skills. There are three main points to consider while designing your program:

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.

If your output does not look exactly like mine (doing a diff on my output against yours should print nothing), be prepared to lose significant points.

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.

DO NOT, I repeat, DO NOT turn in any files that are not required for the final compilation of your assignment. Do not turn in your temporary .cc files or your saved/olded revisions of your .cc files. If you turn in files that aren't required for your assignment, it hinders the grading processes. You will be docked points if you turn in extraineous files.

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!