//-------------------------------------------------------------------- // // Laboratory 6, In-lab Exercise 1 shell storesim.cs // // Store simulation program // //-------------------------------------------------------------------- // Simulates the flow of customers through a line in a store. #include #include #include #include "queuelnk.cpp" using namespace std; void main () { Queue custQ; // Line (queue) of customers containing the // time that each customer arrived and // joined the line int simLength, // Length of simulation (minutes) minute, // Current minute timeArrived, // Time dequeued customer arrived waitTime, // How long dequeued customer waited totalServed = 0, // Total customers served totalWait = 0, // Total waiting time maxWait = 0, // Longest wait numArrivals = 0; // Number of new arrivals cout << endl << "Enter the length of time to run the simulator : "; cin >> simLength; for ( minute = 0 ; minute < simLength ; minute++ ) { // Dequeue the first customer in line (if any). Increment // totalServed, add the time that this customer waited to // totalWait, and update maxWait if this customer waited // longer than any previous customer. // Determine the number of new customers and add them to // the line. } cout << endl; cout << "Customers served : " << totalServed << endl; cout << "Average wait : " << setprecision(2) << double(totalWait)/totalServed << endl; cout << "Longest wait : " << maxWait << endl; }