Page 3 of 3 First 123
  • Jump to page:
    #31
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    20
    Rep Power
    0
    Well the code needs to get the first customer from the queue which is customer 1 then process it by using the (.remove) method and then it must out the customer and the time customer was processed.

    But im getting confused with the user input nth cashiers station ?
  2. #32
  3. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,711
    Rep Power
    347
    time in queue is from when a customer arrives in the queue (not all customers arrive at the same time) to when there is a cashier available to process him.
    The customer's arrival time needs to be recorded to be able to compute time in queue.

    The processing time at the cashier is what keeps a customer waiting in the queue.
    When a customer arrives at a cashier there needs to be a random time from min to max that the cashier is blocked processing the customer.

    What kind of class are you taking? What has the instructor taught about this kind of program and process?
  4. #33
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    20
    Rep Power
    0
    Here what im able to do so far however I still dont known how to implement to record the time when the customer enters the queue and exists the queue.

    Code:
    public class Station 
    {
    	public static Queue<String> line = new  LinkedList<String> ();
    	
    	public static void main(String[] args) 
    	{
    		Scanner userinput = new Scanner(System.in);
    		String cashier = userinput.nextLine();
    		System.out.println("Enter the number of Cashiers here: ");
    		
    		String[] customers = {"Naqi", "Monty", "Mohin", "Paal", "Yasmin", "Maighjoo", "Ashish", "Kevin", "Ruhail", "Tony", };
    		int customer = customers.length;
    		
    		for (int x = 0; x < customer; x++ )
    		{
    		int cus = (int) (Math.random() * customer);
    		line.add(customers[cus]);
    		}
    	
    		
    		boolean empty = line.isEmpty();
    		while (!empty == true)
    		{
    			System.out.println(line  + "\n");
    			System.out.println("The queue has " + line.size() + " customers left");
    			System.out.println(line.remove() + " <=== SERVED" + "\n");
    			System.out.println("The queue has " + line.size() + " customers left");
    			System.out.println(line.remove() + " <=== SERVED" + "\n");
    			System.out.println("The queue has " + line.size() + " customers left");
    			System.out.println(line.remove() + " <=== SERVED" + "\n");
    			System.out.println("The queue has " + line.size() + " customers left");
    			System.out.println(line.remove() + " <=== SERVED" + "\n");
    			System.out.println("The queue has " + line.size() + " customers left");
    			System.out.println(line.remove() + " <=== SERVED" + "\n");
    			System.out.println("The queue has " + line.size() + " customers left");
    			System.out.println(line.remove() + " <=== SERVED" + "\n");
    			System.out.println("The queue has " + line.size() + " customers left");
    			System.out.println(line.remove() + " <=== SERVED" + "\n");
    			System.out.println("The queue has " + line.size() + " customers left");
    			System.out.println(line.remove() + " <=== SERVED" + "\n");
    			System.out.println("The queue has " + line.size() + " customers left");
    			System.out.println(line.remove() + " <=== SERVED" + "\n");
    			System.out.println("The queue has " + line.size() + " customer left");
    			System.out.println(line.remove() + " <=== SERVED" + "\n");
    			break;
    		}
    	}
    
    }
  6. #34
  7. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,711
    Rep Power
    347
    What kind of class are you taking? What has the instructor taught about this kind of program and process?

    Also posted at: http://www.javaprogrammingforums.com...imulation.html
    Last edited by NormR; April 1st, 2013 at 03:19 PM.
Page 3 of 3 First 123
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo