Tough Programming Problem, Help Greatly Appreciated

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
SoupaMan
Forum Newbie
Posts: 1
Joined: Tue Feb 21, 2012 8:54 am

Tough Programming Problem, Help Greatly Appreciated

Post by SoupaMan »

I took a course in computers, and I have a slight background in PHP. I was not expecting programming to be apart of the actual class, and it has caught me off guard. I have spent the last weeks fighting with this, trying to understand how I can put it into code properly. Any ideas, code samples, or guidance would be GREATLY appreciated!


Assume the following:
a. Disk spooling is NOT being used.
b. The printer does NOT have a hardware buffer to hold the output while the printer is printing

(The theme music from Mission Impossible is playing faintly in the background).

SIMULATE the following scenario
A hypothetical program computes for three seconds then outputs a variable length record to be printed. The printer takes from 0.75 to 4.75 seconds (average time is 2.75 seconds) to print each output record. (Use a random number generator)

The hypothetical program loops 500 times for each case of software buffers (0, 1, 2, 3, 4, 5, 10, 25, and 100 software output buffers). Calculate the AVERAGE time for the program to “virtually compute and print” a record from the 500 records, for EACH of the 9 choices of buffer.





Thanks again!

-Steve
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: Tough Programming Problem, Help Greatly Appreciated

Post by Eric! »

Make a function to simulate the printer using the range of delays possible taking only one letter at a time. Loop through your buffer filling it as you go based on the size limits until it has printed then report the average elapsed times when the 500 records are done.

Look up how to do random numbers and timers in PHP for a start.
Post Reply