Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Main objective: Simulate 5 Bank Teller lines, similar to the single Bank Teller line that we discussed in class, which is also described in Chapter

Main objective: Simulate 5 Bank Teller lines, similar to the single Bank Teller line that we discussed in class, which is also described in Chapter 8 of the P&C textbook. Customers come into the SlugFest Bank, and they wait on one of the Teller lines. Each input line contains the name of the customer (with no spaces in that name), the number of the Teller line that the customer waits on (from 1 to 5), the arrival time for the customer, and the number of minutes that the customers banking transaction takes. Arrival time for a customer is just the number of minutes since the simulation started that the customer arrived. For example, the input line:

4 Jefferson 25 8

means that customer Jefferson arrives 25 minutes after the simulation started, waits on Teller 4s line, and has a banking transaction that takes 8 minutes.

But that doesnt mean that Jefferson gets to begin her transaction at time 25. 2 There could be other customers who arrived before her who are on line, or who are being served by Teller 4. Youll have to maintain a Queue (subtle hint) of the customers on each Tellers line. Whenever the current customer served by a Teller line finishes her transaction, the next customer on that Tellers line immediately begins to be served by that Teller. So if Teller 4 begins Jeffersons transaction at time 47 and completes Jeffersons transaction at time 55, and the next customer on Teller 4s line (whom well call Madison) requires 4 minutes for his transaction, then Madison will complete his transaction at time 59.

The Simulation begins at time 0. Sometimes there may not be any customers on a Tellers line, so the Teller is idle. The arrival times in the input file are always increasing (or stay the same). That is, youll never find an input line describing a customer arriving at time 72 that is followed by an input line for a customer arriving at an earlier time, such as 71. Two customers might arrive at the same time, but only if they line up for different Tellers. You can assume that there never will be two customers who arrive at the same time and line up for the same Teller.

Output: Your output file should contain a line giving the time at which each customer begins her transaction at a Teller, and another line giving the time at which each customer ends her transaction with a Teller. Note that the begin/end information for all 5 Tellers should appear together in the output. For example, the output might be:

2 Washington begins 40

4 Jefferson begins 47

5 Adams begins 51

4 Jefferson ends 55

4 Madison begins 59

2 Washington ends 62

5 Adams ends 62

2 Lincoln begins 64

4 Madison ends 68

2 Lincoln ends 70

Please follow this format precisely. Note that the simulation time (the last number on each output line) always increases (or stays the same); your output should also follow this rule. Its possible that there will be two (or more) customers who finish their banking transactions at the same time (like Adams and Washington, who both end at time 62). If that occurs, then the smaller Teller number should appear first in the output, which is why 2 Washington ends 62 appears before 5 Adams ends 62.

You must implement your solution to HW4 in Java (not C) using reference-based queues. Furthermore, you have to write your own queue implementation from scratch. You cannot use any built-in libraries for queues or linked lists, nor can you use an ADT for lists or an array-based queue. Please do not submit a question on Piazza asking how many queues you need for HW4; such questions will be deleted. Figuring that out is part of the HW, and moreover, it should be obvious.

Also: Your Reference-Based Queue implementation should have a single external reference, lastNode, not two external references (lastNode and firstNode).

Format: You should provide a Makefile. Running make should create SlugFest.jar. Your program should take two command line arguments, an input file and an output file.

Input: The input file consists of a series of input lines as described above, each (including the last line) ending with an end-of-line.

Output: On running (say) :

java -jar SlugFest.jar my-input.txt my-output.txt

the file my-input.txt should be read in, and the file my-output.txt should be output. The output file should have contents and format as described above.

my-input.txt:

1 Washington 1 8 2 Adams 2 9 3 Jefferson 2 10 4 Madison 2 6 2 Monroe 3 7 1 QuincyAdams 4 5 1 Jackson 5 6 5 VanBuren 5 12 2 Harrison 6 1 5 Tyler 9 3 1 Polk 9 6 4 Taylor 11 6 3 Fillmore 12 5 2 Pierce 15 3 5 Lincoln 16 16 1 Buchanan 17 1

my-output.txt:

1 Washington begins 1 2 Adams begins 2 3 Jefferson begins 2 4 Madison begins 2 5 VanBuren begins 5 4 Madison ends 8 1 Washington ends 9 1 QuincyAdams begins 9 2 Adams ends 11 2 Monroe begins 11 4 Taylor begins 11 3 Jefferson ends 12 3 Fillmore begins 12 1 QuincyAdams ends 14 1 Jackson begins 14 3 Fillmore ends 17 4 Taylor ends 17 5 VanBuren ends 17 5 Tyler begins 17 2 Monroe ends 18 2 Harrison begins 18 2 Harrison ends 19 2 Pierce begins 19 1 Jackson ends 20 1 Polk begins 20 5 Tyler ends 20 5 Lincoln begins 20 2 Pierce ends 22 1 Polk ends 26 1 Buchanan begins 26 1 Buchanan ends 27 5 Lincoln ends 36

Please use the format shown below precisely for your output lines, with no space at the beginning of the line, and single spaces separately tokens/words from each other.

2 Washington begins 40

4 Jefferson begins 47

5 Adams begins 51

4 Jefferson ends 55

4 Madison begins 59

2 Washington ends 62

5 Adams ends 62

2 Lincoln begins 64

4 Madison ends 68

2 Lincoln ends 70

In your output, earlier times must always appear before later times, as shown in the example above. But multiple things may happen at the same time. For example, Customer X might begin at time 40 on line 3, Customer Y might begin at time 40 on line 2, and another Z might end at time 40 on line 2. Events occurring at the same time for line 2 should always appear before events for line 3, and similarly for other lines numbers.

And when two events on the same line occur at the same time, the ending event should obviously appear before the beginning event. That is, Customer Z ends her transaction on line 2 before Customer Y begins his transaction on line 2.

So for the X, Y and Z events occurring at time 40, the output should be: 2 Z ends 40 2 Y begins 40 3 X begins 40

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

More Books

Students also viewed these Databases questions

Question

Describe Table Structures in RDMSs.

Answered: 1 week ago