For school I have to write a program that calculates the probability of 0 to 10 planes attempting to land in any-minute period at an airport during peak arrival times.
I think I don't understand the equation:
a(exponent x) e(exponent -x)
over
x!
x= the number of plane arrivals per minute
a= average number of arrivals per minute
e= Euler's number (2.71828)
EDIT: Assume the average number of arrivals per minute is 3
I know the first number is 0.0498 and the program gets that one right.
The second number should be 0.1494 and the tenth number should be 0.0008 , but my program doesn't get those right.
here is my source code so far, any help would be greatly appreciated.
#include<iostream>
#include<iomanip>
#include<math.h>
using namespace std;
int main()
{
double c, sum=0,a=3, b, x, d, e, f;
double long long fact =1, ;
cout<<"Probability Table\n";
cout<<"*****************\n";
for(x=0; x<=10; x++)//x goes from 1 to 10
{
for (e=1; e<=x; e++ )
sum=sum+x;
fact *= e;
d=pow(3, x);
c=pow(2.71828, -a);
b=d*c;
f=b/fact;
cout<<"\nProbability of "<<x<<" planes arriving is "<<setprecision(3)<<f;
}
system ("Pause");
return 0;
}