I am writing a java program for the traffic Density using the poisson Distribution...

maddy

New member
...formula.? I wrote the program but still i am getting error . Can any body help me to do it right? Please ! Here is my detail program.
import java.util.Scanner;

/**
*
* @author Maaddy
*/
public class Chap6Prob10 {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
double Probability;
double t=0; // Time interval
double lemtda=0; // Given value in a minute
int n,k; // Total numbers of car passing in a minute
Scanner keyboard= new Scanner(System.in);
for(k=0;k<=5;k++){
System.out.print("The total number of cars in a minute:");
k = keyboard.nextInt();
System.out.print("The total time to be calculated in:");
t= keyboard.nextDouble();
System.out.print("The given value of the constant(lemtda):");
lemtda= keyboard.nextDouble();
}
n= keyboard.nextInt();

for(k=0;k<=5;k++){
Probability= ((Math.pow(Math.E,(-lemtda*t))* Math.pow((lemtda*t),k))/Chap6Prob10.fact(n));

}
System.out.println("The probability of the car passing through the given road is:"+ chap6prob10.Main);

public static int fact(int n){
int answer;
System.out.println("In fact:n"+n);
if (n>=1)
answer=n*fact(n-1);
else
answer= 1;
return answer;
 
Back
Top