<p>I\'m trying to write simulation program for waiting in a line. I have most of
ID: 3631865 • Letter: #
Question
<p>I'm trying to write simulation program for waiting in a line. I have most of the classes coded (minus some empty methods in a couple) and some pseudo code for the main program written. <br /><br />I'm looking for help filling in the empty methods and writing the program using the pseudo code.<br /><br />I have all the code posted on pastebin: http://pastebin.com/k1XMXkGT<br /><br />This is the pseudo code:</p><p><br />// Simulation Pseudo Code<br /><br />public class SimulationProgram<br />{<br /> //member variables<br /> private static int simulationTime;<br /> private static int numberOfServers;<br /> private static int transactionTime;<br /> private static double arrivalProbability;<br /><br /> create customer wait queue<br /> <br /> create server list -- specify # of servers<br /> <br /> foreach( clock time unit )<br /> {<br /> update servers<br /> <br /> update customer wait queue<br /> <br /> if( customer arrives )<br /> {<br /> create customer record<br /> ( cust#, clock, waitTime=0, transactTime )<br /> <br /> add customer to wait queue<br /> }<br /> <br /> if( free server )<br /> {<br /> remove customer from wait queue<br /> <br /> add customer to server<br /> }<br /> <br /> generate statistics report<br /> <br /> }//end foreach <br /> <br />}//end class SimulationProgram</p>
Explanation / Answer
public class asgnthr { public static double expo(double mean) { double ran = Math.random(); double ex = -mean * Math.log(ran); return ex; } public static void main(String[] args) { double meanInterArrival = 10.2; double meanService = 1.0; double clock = 0; double nextArrival; double nextDeparture; double closingTime = 1000; boolean serverIdle = true; boolean closed = false; int customerCount = 0; double customerWaitTime = 0; double totalWaitTime = 0; nextArrival = clock + expo(meanInterArrival); nextDeparture = 5000; while (!closed) { if (nextArrivalRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.