• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help with queue program  RSS feed

Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello.....is there any one who can help me with completing this problem?

I'm learning about Queue and this program is assigend to me as last program

of this semester...

I want to get it worked...but..I have no idea how to deal with this program..

So..is there any one who can complete this program so it works?

It's due date is tomorrow and...I hope someone can spend some time for it..

I know it's actaully too much to ask someone to spend his own time for

my work...but please consider it as you are rescuing someone from the bottom

hell.. I will fail if it is not finished by tomorrw...Please do me this biggest favor of

my whole life...

This is the driection of the program.

------------------------------------------------------------------------------- -----------------------
The Cafe would like to computerize its seating and waiting procedures.

The dining room has 1 table for 8 customers, 2 tables for 6 customers

and 4 tables for 4 customers. The waiting area can hold up to 20

people. Assuming that the parties exit n the same order that they

enter, write a program that will allow the Cafe to keep track of the

people in the eating area and the people in the waiting area. You may

not separate any party so that they can be seated at different tables.

Your output should show the results of each party entering the

restaurant. If the waiting area is full or will become more than the

allowable amount of people, the party is not to be allowed in.

(Note: number of customers should match the spaces in the table.
Ex> party of 4 only sit on the table for 4 customers. )

(Note: If more than 20 people are in waiting area, print something

like "Sorry we don't have place for you")

The output should look similar to the following:
1. Isle--party of 4 is seated
2. Hood--party of 7 is seated
3. Time--Party of 8 is assigned to the waiting area
4. Gun--party of 12 is not allowed in the restaurant
5. Isle--party of 4 leaves the eating area
6. Hood--party of 7 leaves the eating area
Time--party of 8 is seated
7. Lee--party of 6 is seated


Use the following data for your program.

Final Data:

1. Dean Isle--party of 6 arrives
2. Justin Time--party of 4 arrives
3. Ray Gun--party of 7 arrives
4. Cal Ander--party of 4 arrives
5. Frank Lee--party of 3 arrives
6. Tim Buhr--party of 5 arrives
7. Eve Ning--party of 4 arrives
8. Pam Flet--party of 4 arrives
9. Lee Way--party of 8 arrives
10. Dan DeLion--party of 4 arrives
11. Carol Ling--party of 5 arrives
12. Dean Isle--leaves
13. Dan Druff--party of 4 arrives
14. Justin Time--leaves
15. Ray Gun--leaves
16. Barb Ell--party of 3 arrives
17. Bill Board--party of 8 arrives
18. Don Key--party of 6 arrives
19. Chuck Wagon--party of 4 arrives
20. Cal Ander--leaves
21. Frank Lee--leaves
22. Tim Buhr--leaves
23. Joe Kuhr--party of 6 arrives
24. Eve Ning--leaves
25. Will Power--party of 10 arrives.
------------------------------------------------------------------------------- ------------------------

And the program I and my friend tried is here:

------------------------------------------------------------------------------- -------------------------

import java.util.*;

public class Queue2
final static byte z = 4;

public static void main (String[] args)
ListQueue[] wait = new ListQueue[5];
ListQueue[] Seat = new ListQueue[5];
byte[] table = {0,3,1,3,2};
byte WaitArea = 0;

for (int i = 0; i < Wait.length; i++)
Wait = new ListQueue();
Seat = new ListQueue();

Family Isle= new Family("Dean Isle" , 6);
WaitArea = arrive(Isle, Seat, table, waitArea);

Family JTime = new Family("Justin Time" , 4);
WaitArea = arrive(JTime, Seat, table, waitArea);

Family Gun= new Family("Ray Gun" , 7);
WaitArea = arrive(Gun, Seat, table, waitArea);

Family Ander= new Family("Cal Ander" , 4);
WaitArea = arrive(Ander, Seat, table, waitArea);

Family Lee= new Family("Frank Lee" , 3);
WaitArea = arrive(Lee, Seat, table, waitArea);

Family Buhr= new Family("Tim Buhr" , 5);
WaitArea = arrive(Buhr, Seat, table, waitArea);

Family Ning= new Family("Eve Ning" , 4);
WaitArea = arrive(Ning, Seat, table, waitArea);

Family Flet= new Family("Pam Flet" , 4);
WaitArea = arrive(Flet, Seat, table, waitArea);

Family Way= new Family("Lee Way" , 8);
WaitArea = arrive(Way, Seat, table, waitArea);

Family DeLion= new Family("Dan DeLion" , 4);
WaitArea = arrive(DeLion, Seat, table, waitArea);

Family Ling= new Family("Carol Ling" , 5);
WaitArea = arrive(Ling, Seat, table, waitArea);
WaitArea = depart(Isle, Wait, Seat, table, WaitArea);

Family Druff= new Family("Dan Druff" , 4);
WaitArea = arrive(Druff, Wait, Seat, talbe, WaitArea);
WaitArea = depart(JTime, Wait, Seat, talbe, WaitArea);
WaitArea = depart(Gun, Wait, Seat, talbe, WaitArea);

Family Ell= new Family("Barb Ell" , 3);
WaitArea = arrive(Ell, Seat, table, waitArea);

Family Board= new Family("Bill Board" , 8);
WaitArea = arrive(Board, Seat, table, waitArea);

Family Dkey= new Family("Don Key" , 6);
WaitArea = arrive(DKey, Seat, table, waitArea);

Family Wagon= new Family("Chuck Wagon" , 4);
WaitArea = arrive(Wagon, Seat, table, waitArea);
WaitArea = depart(Ander, Seat, table, waitArea);
WaitArea = depart(Lee, Seat, table, waitArea);
WaitArea = depart(Buhr, Seat, table, waitArea);

Family Kuhr= new Family("JoeKuhr" , 6);
WaitArea = arrive(Khur, Seat, table, waitArea);
WaitArea = depart(Ning, Seat, table, waitArea);

Family Power= new Family("Will Power" , 10);
WaitArea = arrive(Power, Seat, table, waitArea);

public static byte depart(Family F, ListQueue[] Wait, ListQueue[] Seat, byte[] b, byte W)
byte size = F.mySize;
if (size%2==1) size++;

System.out.println(F.myName + ", party of " + F.mySize + ", has left.");
b[size - z] --;

if (!Wait[Size-z].isEmpty())
Family N = Family ( Wait[Size-z].dequeue());
System.out.println(N.myName + ", party of " + N.mysize + ", has been seated from the waiting area.");
W -= N.mySize;

return W;

public static byte arrive(Family F, ListQueue[] Wait, ListQueue[] Seat, byte[] b, byte W)
\ byte size = F.mySize;
if (size%2==1)
if (size > 8)
System.out.println(F.myName + ", party of " + F.mySize + ", has been seated.");
else if (W <= 20 - size)
Wait[size = z].enqueue(F);
W += F.mySize;
System.out.println(F.myName + ", party of " + F.mySize + ", is in the waiting romm.");
System.out.println(F.myName + ", party of " + F.mySize + ", has been asked to leave.");
return W;

I think one of the problem is that it doesn't have "family class" that supports the
data of parties... I konw it's akward....but please help.............

Thank you so much...bottom of my heart.

[ EJFH: Added more meaningful subject line. ]
[ January 13, 2005: Message edited by: Ernest Friedman-Hill ]
Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I think that your on the right track. I do not see a family class and you have created instances of family.

Why don't you try to create some code for your family class and pass it through the post as a start. We can look at it and tweek it!

I would finish you homework for you but I'm doing someone elses on a different thread .

Give it a shot and let's see what can be done in 7 hours!

Ranch Hand
Posts: 89
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are a few ambiguities here in the spec! If a table for 4 departs and the next in the queue are parties of 8 and 4 respectively can the table of 4 "skip" the queue to take the table or do they have to wait until the table of 8 is seated before they can take their table?
author and iconoclast
Posts: 24217
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Jimmy says, you'll need to write a Family class.

One thing that would help would be to use the standard Java convention of naming variables with a lower class initial letter, and classes with an upper case initial; this makes the code much easier to read at a glance. The easier the code is to read, the easier it is to work on!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!