function [arrivet,departt,ET,NS]=oneservQ(start_time,mu)
% initializes one server queue
% runs arrivals and departures until clock time T assumed <9999
%mu is service rate. 
% intialization step. clock=clock time. Keeps track of NA and ND=number of arrivals,departures
% by present time. EL=system state=(TA,TD)=time of next arrival, time of next departure
clock=7;   T=12;  
NA=0;
ND=0;
EL=[7,9999];
%ET=eventtimes, NS=number in system (immediately after) times ET
ET=[];
NS=[];    

arrivet=[];    %initialize the arrival and departure times of customers.
departt=[];
while(clock<T)
  if (EL(1)<EL(2))
  % next event is an  arrival. advance clock and schedule a new arrival
  [clock,EL,NA]=arrival(clock,EL,NA,100);
  arrivet=[arrivet clock];
  ET=[ET,clock];
  NS=[NS NA-ND];
  % if system was empty, schedule a  service time for this customer
    if (NA-ND==1)
       EL(2)=max(start_time,clock)+servicet(mu);  % office opens at start_time
     end
  else
    %next event is a departure. advance clock and schedule a new departure.
    [clock,EL,ND]=departure(clock,EL,NA,ND,mu);
    departt=[departt clock];
    ET=[ET,clock];
    NS=[NS NA-ND];
  end
end
% plots the number in system versus the time.
stairs(ET,NS);  xlabel('time') ; ylabel(' number in system')
%average time in system and average number
disp(['average time in system  ' num2str(mean(departt-arrivet(1:length(departt))))])
k=length(ET);    
disp(['average number in system  ' num2str(sum(NS(1:k-1).*diff(ET))/ET(k))])
