In a single-file project called Cashiers.java, code a user-defined class called Cashiers that consists of:

  • A 3 x 6 integer matrix to store numbers of up to 6 customers in the lines (queues) of 3 cashiers
  • Two arrays, front and back, each of size 3, to follow a circular queue protocol
  • An array, currentSize, of size 3, to keep track of the size of each line
  • A single variable customer, initially 1, which increments every time a new customer joins a queue.

The following methods need to be coded for this class:

  • A constructor Cashiers()
  • clear()
  • fill()
  • display()
  • int dequeue(int which), where which is the queue number 0, 1, or 2
  • boolean enqueue(), which picks the shortest queue (if a tie, the lowest number)

Use the Cashiers class also to contain a main method that repeatedly asks the user:

Input command E or 1 or 2 or 3 or F or C or Q

Permit lower case by converting to upper case. Validate with the message

Invalid input!

if the user does not input one of these 7 options. Here are the actions that need to be coded, using one object of the user-defined class Cashiers:

  • E = enqueuer, using the shortest queue (if a tie, use the lowest-numbered queue)
  • 1, 2, or 3 = dequeuer from queue 0, 1, or 2.
  • F = clear all queues and then fill up again
  • C = clear all queues
  • Q = quit

After each input, display the data structure again. Here is a sample display:

0 4F 7 10B 0 0
0 0 8F 11B 0 0
3F 6 9 12B 0 0

For each entry, give the customer number (0) if location not used, and list F or B or FB after the number as appropriate, where F labels the front and B the back of the queue.

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.