Hi in this program i want it to run for 720 loops but it keeps stoping short for some reason. There is no compilation error or runtime error.

import java.util.LinkedList;
import java.util.Random;

public class Simulation {

	private LinkedList<Customer> customerList;
	private int minutesThatHavePast;
	private int customerNumber;
	private int customerProcessTime;
	private int arrivingcustomer;
	private int theProccessTimeForThisCustomer;
	
	public Simulation(){
		Random generator = new Random();
		arrivingcustomer= generator.nextInt(4);
		minutesThatHavePast=0;
		customerList = new LinkedList<Customer>();
		createCustomer();
	}
	
	public void createCustomer(){
		
		arrivingcustomer--;
		
		
			if(arrivingcustomer==0)
			{
			Random generator = new Random();
			theProccessTimeForThisCustomer = generator.nextInt(4);
			customerNumber++;
			
			customerList.addLast(new Customer(customerNumber, minutesThatHavePast, 
					theProccessTimeForThisCustomer));
					
			System.out.println("Customer Number "+customerNumber+
					 " has entered the queue"); 
					 
			arrivingcustomer= generator.nextInt(4);	
				
			determineIfTheCustomerIsFinished();
			
			addToMinutesHavePast();
			}
			else if(customerList.isEmpty()== false)
			{
			
			determineIfTheCustomerIsFinished();
			
			addToMinutesHavePast();
		}
			else
			addToMinutesHavePast();
	
				
	}
	
	public void addToMinutesHavePast()
	{
		if(minutesThatHavePast<=720) 
		{
			minutesThatHavePast++; 
			customerProcessTime++;
			createCustomer();
		}
		
		
	}
	
	
	public void determineIfTheCustomerIsFinished()
	{
		
		Customer customerBeingServiced=customerList.getFirst();
		
		if (customerBeingServiced.getProcessTime()==customerProcessTime)
		{
			System.out.println("Customer Number "+
				customerBeingServiced.getCustomerNumber()+" has left the queue");
			
			customerList.removeFirst();
			
			customerProcessTime=0;
		}
	}
	
	public static void main(String args[]){
		
		new Simulation();
		
	}
	
}
public class Customer {

	private int arrivalTime;
	private int exitTime;
	private int timeInQueue;
	private int customerNumber;
	private int processTime;
	
	Customer(int customerNumber, int arrivalTime, int exitTime, int timeInQueue,
			int processTime){
		this.arrivalTime= arrivalTime;
		this.exitTime=exitTime;
		this.timeInQueue=timeInQueue;
		this.customerNumber=customerNumber;
		this.processTime=processTime;
	}
	
	Customer(int customerNumber, int arrivalTime, int processTime){
		this.customerNumber=customerNumber;
		this.arrivalTime=arrivalTime;
		this.processTime=processTime;
	}
	
	public void setArrivalTime(int timeArrived){
		timeArrived = arrivalTime;
	}
	
	public int getArrivalTime(){
		return arrivalTime;
	}
	
	public void setExitTime(int timeLeft){
		timeLeft = exitTime;
	}
	
	
	public int getExitTime(){
		return exitTime;
	}
	
	public int getTimeInQueue(){
		timeInQueue= exitTime-arrivalTime;
		return timeInQueue;
	}
	
	public void setCustomerNumber(int number){
		customerNumber=number;
	}
	
	public int getCustomerNumber(){
		return customerNumber;
	}
	
	public void setProcessTime(int time){
		processTime=time;
	}
	
	public int getProcessTime(){
		return processTime;
	}
}

Looks pretty intricate. Since you're not getting a compiler or run-time error, it's a logic error. The way to track those is to get a look into the program. What's happening when?

So I'd start by looking to see how many times createCustomer is actually called.
Create a static int called counter, initialize it to zero, and then at the start of create customer, print it and increment it.

That'll give you a good clue as to what's happening here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.