Project Description

The management at INITECH corporation is cleaning house and wants to simulate the work of its office personnel to provide a productivity threshold to measure existing employees. You are to write the simulation for the clerk who processes maintenance requests at INITECHs corporate headquarters.

Requests for service are sent as a form to the processing clerk to be prioritized, validated, and approved before being sent off to be fulfilled. You are to write a program to simulate forms processing by an office clerk. For the simulation, individual form information, called a Request, is obtained from an input file.

For implementation purposes, each Request has a ID number, execution time required to process the request (this includes the time needed to obtain approval to fulfill the service requests from senior officials in the company), an entry time (This is the time the request was made. Note that it must be later than all requests with a lower ID number), a priority (from 1 to 4 where 1 is the highest priority), and a description of the service being requested. see image.

When a request is first read from the input file, it will be handled immediately if the clerk is free. Otherwise, it will be placed in the input priority queue. Requests are not processed completely all at once because the clerk wants to distribute his attention fairly. The clerk works on a request for a fixed unit of time (called a time slice). At the end of the time slice, the clerk pauses. The current Request is placed on a Pending Requests stack, where it waits for its next share of clerks time.

When implementing the simulation, write a Clerk class that will process the Requests. The Clerk will maintain both the incoming queue of Request objects and the stack of pending Requests.

As previously stated, on every time slice, the current Request (if there is one) is placed on the Pending Requests stack; if theres a Request waiting to be processed at the front of the input queue that has a higher priority than the Request at the top of the Pending Requests stack, the higher priority Request is removed from the input queue to become the current Request. Otherwise, the Request at the top of the stack is moved back to the Clerk from the Pending Requests stack. All Requests that are processed by the Clerk come from either the input queue or the Pending Requests stack. So, at the beginning of a time slice, the Request having the highest priority is moved from the priority queue or the Pending Requests stack and processed for a time slice.

After a Request has received its designated amount of processing time, it is dispatched to be fulfilled.

Figure 1 gives an example input file showing the format. see image.

..

  • Note that Request ID numbers are sequential beginning with 1 and that each progressive Request must enter the system at a later time than the previous Request.
  • The Clerk will work until the input queue and Pending Requests stack are both empty and there are no more Request in the input file.
  • Requests enter the input queue only at their scheduled input time. Any Requests trying to enter the queue after their scheduled time should be rejected with an appropriate error message.
  • The Clerk is active only while a Request is being processed; as mentioned earlier, processing of Requests is automatically interrupted each time slice in order to check priorities.
  • Requests are said to have completed one processing cycle at the end of each time slice that they are processed by the Clerk, after all form movement has taken place.
  • Your program should report when Requests first enter the Clerks office (when they are placed in the input queue), when they begin processing, when they finish processing, and when they finally leave the office to be fulfilled. You must use the following format to report system events:
6: Request #3 arrives
7: Request #1 begins processing
12: Request #3 finishes processing
16: Request #5 dispatched to be fulfilled

When all Requests are processed, you are to report the average wait times in both the input queue and the Pending Requests stack. Average wait time is computed by dividing the total wait time all Requests spent in a queue or stack by the total number of Requests that were processed by the Clerk. Note that a Request waits only if it remains in a queue or stack at the end of a time slice. All program output is to be written to a file called < YourLastName>Output.txt. The standard printHeading() information should be sent to this file before any of the simulation results.

Your program must be able to retrieve the name of the input file from the command line and provide appropriate recovery if the file name is missing or incorrect. Your main program file must be named Project4.java and you should create both Request.java and Clerk.java source code files to model these two entities.

Follow style and documenting examples given in class for earlier projects. Each program file must begin with a comment block with your name, program name, course number, etc. The block must also include the purpose, input, and output of the program.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.