

// This is how the output should look. Everything is correct with my arrival and departure times. I also have the correct output of 4 people for total number of people processed. My problem is that i am getting 15.25 for the average time spent waiting. Please help me. The correct answer is below, 3.25 Processing an arrival event at time: 20 Processing an arrival event at time: 22 Processing an arrival event at time: 23 Processing a departure event at time: 26 Processing an arrival event at time: 30 Processing a departure event at time: 30 Processing a departure event at time: 32 Processing a departure event at time: 35 Final statistics: Total number of people processed: 4 Average amount of time spent waiting: 3.25
Statistics.cpp
#include
using namespace std;
#include "Statistics.h"
Statistics::Statistics()
: countTotal(0),
count1(0),
count2(0),
count3(0),
waitTimeTotal(0),
waitTime1(0),
waitTime2(0),
waitTime3(0) {
}
Statistics::~Statistics() {
}
void Statistics::addEvent(const Event& event) {
// Use arrivals to count the total number of
customers and tally
// the numbers of customers that enter each
line.
if (event.getType() == ARRIVAL) {
#ifdef TESTING
cout << "Processing arrival
event "
<< event.getNumber()
<< " in queue "
<< event.getLine()
<< " at time "
<< event.getTime()
<< endl;
#endif
++countTotal;
if (event.getLine() == 1) {
arrivalEvents1.enqueue(event);
++count1;
}
else if (event.getLine() == 2)
{
arrivalEvents2.enqueue(event);
++count2;
}
else {
arrivalEvents3.enqueue(event);
++count3;
}
}
// Use departures to calculate total wait time and
cumulative wait
// time for each line.
else {
#ifdef TESTING
cout << "Processing departure
event "
<< event.getNumber()
<< " at time: "
<< event.getTime()
<< " in line number "
<< event.getLine();
#endif
Event arrivalEvent;
bool eventWaiting = false;
if (event.getLine() == 1
&& !arrivalEvents1.isEmpty() ) {
arrivalEvent =
arrivalEvents1.peekFront();
arrivalEvents1.dequeue();
waitTime1 +=
event.getTime() - (arrivalEvent.getTime() +
arrivalEvent.getDuration() );
eventWaiting =
true;
}
else if (event.getLine() == 2
&& !arrivalEvents2.isEmpty() ) {
arrivalEvent =
arrivalEvents2.peekFront();
arrivalEvents2.dequeue();
waitTime2 +=
event.getTime() - (arrivalEvent.getTime() +
arrivalEvent.getDuration() );
eventWaiting =
true;
}
else if (event.getLine() == 3
&& !arrivalEvents3.isEmpty() ) {
arrivalEvent =
arrivalEvents3.peekFront();
arrivalEvents3.dequeue();
waitTime3 +=
event.getTime() - (arrivalEvent.getTime() +
arrivalEvent.getDuration() );
eventWaiting =
true;
}
if (eventWaiting) {
#ifdef TESTING
cout << "
event "
<< arrivalEvent.getNumber()
<< " waited: "
<< event.getTime() - (arrivalEvent.getTime() +
arrivalEvent.getDuration() );
#endif
waitTimeTotal +=
event.getTime() - (arrivalEvent.getTime() +
arrivalEvent.getDuration() );
}
#ifdef TESTING
else {
cout << " no
events waiting.";
}
cout << endl;
#endif
}
}
void Statistics::reportStats() const {
cout << "\nFinal Statistics:"
<< endl
<< " Total number
of people processed: "
<<
countTotal
<< endl
<< " Total wait
time: "
<<
waitTimeTotal
<< endl
<< " Average
amount of time spent waiting: ";
if (countTotal != 0) {
cout << (double)waitTimeTotal
/ (double)countTotal;
}
else {
cout << 0.0;
}
cout << endl
<< "\n Totals for
Teller 1:"
<< endl
<<
" People processed: "
<< count1
<< endl
<<
" Wait time: "
<< waitTime1
<< endl
<<
" Average wait time: ";
if (count1 != 0) {
cout << (double)waitTime1 /
(double)count1;
}
else {
cout << 0.0;
}
cout << endl
<< "\n Totals for
Teller 2:"
<< endl
<<
" People processed: "
<< count2
<< endl
<<
" Wait time: "
<< waitTime2
<< endl
<<
" Average wait time: ";
if (count2 != 0) {
cout << (double)waitTime2 /
(double)count2;
}
else {
cout << 0.0;
}
cout << endl
<< "\n Totals for
Teller 3:"
<< endl
<<
" People processed: "
<< count3
<< endl
<<
" Wait time: "
<< waitTime3
<< endl
<<
" Average wait time: ";
if (count3 != 0) {
cout << (double)waitTime3 /
(double)count3;
}
else {
cout << 0.0;
}
cout << endl;
}
Statistics.h
#ifndef STATISTICS_H
#define STATISTICS_H 1
#define TESTING 1
#include "Event.h"
#include "LinkedQueue.h"
class Statistics {
private:
int countTotal;
int count1;
int count2;
int count3;
Time waitTimeTotal;
Time waitTime1;
Time waitTime2;
Time waitTime3;
/** Arrival events get stored until we encounter
the next departure
* event. This arrival along with the departure
are then used to
* generate the wait time of this arrival.
*/
LinkedQueue
LinkedQueue
LinkedQueue
public:
Statistics();
virtual ~Statistics();
/** Adds 'event' to the statistics collected so
far.
*
* If 'event' is an arrival event, increment
'countTotal' and the
* count associated with the line this customer
is in and store it
* for use with the next departure event.
*
* If 'event' is a departure event, calculate the
wait time for
* this customer and add it onto 'waitTimeTotal'
and add it to the
* wait time associated with the line this
customer was in. */
void addEvent(const Event& event);
/** Output a report of the statistics for this
simulation. */
void reportStats() const;
};
#endif
This is how the output should look. Everything is correct with my arrival and departure times....
Implement the event-driven simulation of a bank that this chapter described. A queue of arrival events will represent the line of customers in the bank. Maintain the arrival events and departure events in an ADT event list, sorted by the time of the event. Use a reference-based implementation for the ADT event list The input is a text file of arrival and transaction times. Each line of the file contains tiie arrival time and required transaction time for a customer....
Consider a single-server queueing system with arrival and service details as: Interarrival times: 3, 2, 6, 2, 4, 5 Service times: 2, 5, 5, 8, 4, 5 Prepare a table show below for the given data. Stop simulation when the clock reaches 20. Write a Java program, to implement this single-server queueing system, print out the table shown below: You should create a future event list in your Java code, and print out the contents of FE list in each...
Solve it for java
Question Remember: You will need to read this assignment many times to understand all the details of the you need to write. program Goal: The purp0se of this assignment is to write a Java program that models an elevator, where the elevator itself is a stack of people on the elevator and people wait in queues on each floor to get on the elevator. Scenario: A hospital in a block of old buildings has a nearly-antique...
I am having trouble trying to output my file Lab13.txt. It will
say that everything is correct but won't output what is in the
file. Please Help
Write a program that will input data from the file
Lab13.txt(downloadable
file);
a name, telephone number, and email
address.
Store the data in a simple local array to the main
module, then sort the array by the names. You should have several
functions that pass data by reference.
Hint: make your array large...
In Java The fancy new French restaurant La Food is very popular for its authentic cuisine and high prices. This restaurant does not take reservations. To help improve the efficiency of their operations, the Maitre De has hired you to write a program that simulates people waiting for tables. The goal is to determine the average amount of time people spend waiting for tables. Your program will read in a list of event descriptions from a text file, one description...
PYTHON The program needs to process the arrival and departure of each patient documented in the patient data file. While processing each patient, send the following output to an output file: a.Use your two new functions to initially print out a "0". b. As each patient arrives, print out the name of the patient & the time that they arrive at. c. Update the billboard counter to indicate that the wait time has increased. d. Print out the new billboard...
My answer is supposed to look like the table above, but I am
struggling. I am a novice at Oracle SQL and I just don't understand
what I am doing wrong here....Below is the code I used and the
results that I got. I don't understand why each Customer Id (CID)
isn't each returning their own unique value.
Q1 (7 Points) Use ONE SQL statement to show the total number of actual hours for each customer. In the output, show...
build a bank simulator system using the C++ STL queue library.
You are required to create your
own ADT for that system that:
First, Read from a file the data of incoming customers which
includes
ArrivalID, StartTime, and ProcessTime.
You have one line in your Bank in which you will serve your
customers as per to their arrival time.
For example if you read the following data from the file
A 1 5
B 2 5
C 4 5
D...
build a bank simulator system using the C++ STL queue library.
You are required to create your
own ADT for that system that:
First, Read from a file the data of incoming customers which
includes
ArrivalID, StartTime, and ProcessTime.
You have one line in your Bank in which you will serve your
customers as per to their arrival time.
For example if you read the following data from the file
A 1 5
B 2 5
C 4 5
D...
Hello, I am having some trouble with a supermarket checkout simulation program in C++. What I have so far just basically adds customers to the queue and prints when they arrive. I am struggling with how to implement a way of keeping track of when a given customer finishes(I will attach what I have so far). I had already created queue and node classes (with headers and cpp files) that I modified in my attempt. I would be very grateful...