Here is the assignment I get:
*****
Write an email simulator that processes mail at an average of 40 messages per minute. As messages are received, they are placed in a queue.assume that the messages arrive at an average rate of 30 messages per minute.messages must arrive randomly.
Each minute, you can dequeue up to 40 messages and send them. Assume that 25% of the messages in the queue cannot be sent in any processing cycle.use a random number to determine whether a given message can be sent. If it can’t be sent, enqueue it.
Run the simulation for 24 hours, At the end of the simulation, print the statistics that show:
-The total messages processed.
-The average arrival rate.
-The average number of messages sent per minute.
-The average number of messages in queue in a minute.
-The number of messages sent on the first attempt, the number sent on the second attempt, and so forth.
-The average number of times messages had to be requeued (do not include the messages sent the first time in this average)
********
I did the following part but have no idea to continue it, I appreciated it if you help me with a piece of pseudo code or something
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
#include <iostream>
using namespace std;
#define SIZE 40
class Queue {
int queue[SIZE];
int head, tail;
public:
Queue();
void Enq(int num);
void Deq();
void Display();
};
Queue::Queue(){
head = tail = 0;
}
void Queue::Enq(int num){
int newtail = (tail+1)%SIZE;
if(newtail!=head) //queue is'nt full
{
queue[tail]=num;
tail=newtail;
}
else
{
cout<<"\n ***Queue is full***\n";
}
}
void Queue::Deq(){
if(head == tail) {
cout << "Queue is empty\n";
}
head = (head+1) % SIZE;
}
void Queue::Display(){
for(int i=head;i!=tail;i=(i+1)%SIZE)
cout<<queue[i]<<" ";
cout<<endl;
}
int main(){
Queue EmailSim;
return 0;
}
|