Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Programming problem: (20 pts) Use computer simulation to verify the Post office

ID: 3740954 • Letter: P

Question

Programming problem: (20 pts) Use computer simulation to verify the Post office paradox. Post office paradox: and X2) are currently doing transactions (buying stamps and sending express mails) with two postmen on two counters. He waits until a customer (whoever the first, denoted as X1) finishes transaction and move to the counter to do his own transactions. Assume the customer transactions of both postmen follow the same exponential distribution. Due to the memoryless property, at the moment X3 move to counter to do transaction, he will have the same probability of finishing his transaction as customer X2 does even though X2 has been doing transaction for a while. A customer X3 walks into the post office and sees two other customers XI

Explanation / Answer

Answer:

#include <iostream>
using namespace std;

int main()
{
int value, trial, count = 0, input[50], test, Chance = 5000;
double total;


function1(input, value);
test = 0;

for (value = 2; value <= 50; value++)
{
  
test = 0;
for (trial = 0; trial < Chance; trial++)
{

for (int i = 0; i < value, i++)
{
input[value] = (rand() % 365) + 1;
  
for (i = 1; i < value; i++)
{

for (int j = 0; j < i-1; j++)
{
  
for (int k = j +1; k < i; k++);
}
}
}
}
}

bool function1(int input[], int value)
{
  
if (input[j] == input[k])
{
value++;
}

total = (test / 5000.0);
cout << "For " << value << " value, the probability of two input is about " << total << endl;

}

return 0;
}