I have a Java program here, it is work fine with other guys but when I use onlin
ID: 3765731 • Letter: I
Question
I have a Java program here, it is work fine with other guys but when I use online Java compiler it gave me errors
So can you please fix it and send me shoot screen of the run time results.
----------------------------------------------
Q-
The Poisson function,
r -C
P(r) = C * e / r! where C = the distribution average, is useful for modeling a distribution when the probability of any one occurrence of P(r) is extremely small and r is the number of occurrences of the event. Applying this average to message volumes and interarrival rates, C = * T where = message volume and T = interarrival rate, would imply:
r (- T)
P(r) = ( T) * e / r!
Assume the special case r = 0 (no messages arrive for a specific length of time) -- ie
0 (- T) (- T)
(T) * e / 0! = e
t=T
Let us say that f(t)dt represents the probability of "one arrival within T units of
t=0
time after prior arrival." Therefore the probability of no messages
(- T) t=T t=T (- T)
e = 1 - f(f)dt and f(t)dt = 1 - e
t=0 t=0
For purposes of simulation let the integral be represented by a random number RN such that 0 <= RN < 1.
(- T) (-T)
Thus 1 - e = RN, (1 - RN) = e , LN(1 - RN) = - T and
-1/ * LN(1 - RN) = T = interarrival time.
Develop a simulation program to accomplish the following:
1) Ask for and accept message volume per hour, Lambda.
2) Convert this volume to message volume per second, Lambda/3600.
3) Ask for and accept the number of simulations desired.
4) Ask for and accept a random number generator seed.
5) Perform the simulation loop to determine and print interarrival
times for Lambda where RN is determined by a random number
generator function.
6. Compute the average message interarrival time = sum of all interarrival times / count.
Use volumes of 3600 and 7200 with 100 simulations each.
----------------------------------------
First run:
volume = 3600
number of simulation = 100
Second run:
volume = 7200
number of simulation = 100
-------------------------
The Java code
Using System;
namespace poisson_function
{
Class poisson
{
Static void main(string[]args)
{
int simu;
Double RanNum, Lamb ,log;
Double T,AT, SumT =0.0;
Console.WriteLine(“ Enter the volume “);
Lamb=int.parse(Console.ReadLine());
Console.WriteLine(“”);
Lamb=Lamb/3600;
Console.Write(“Enter the simulation number”);
Simu=int.parse(Console.ReadLine());
Console.WriteLine(“”);
For (int i=0; i<simu;i++)
{
RanNum =random.NextDouble();
T=(-1/Lamb)*Math.Log(1- RanNum);
SumT = SumT +T;
Console.WriteLine( “ Arrival Time [{0}]={1}”, i+1, T);
}
AT= SumT /simu;
Console.Read();
}
}
}
Explanation / Answer
Using System;
namespace poisson_function
{
Class poisson
{
Static void main(string[]args)
{
int simu;
Double RanNum, Lamb ,log;
Double T,AT, SumT =0.0;
Console.WriteLine(“ Enter the volume “);
Lamb=int.parse(Console.ReadLine());
Console.WriteLine(“”);
Lamb=Lamb/3600;
Console.Write(“Enter the simulation number”);
Simu=int.parse(Console.ReadLine());
Console.WriteLine(“”);
For (int i=0; i<simu;i++)
{
RanNum =random.NextDouble();
T=(-1/Lamb)*Math.Log(1- RanNum);
SumT = SumT +T;
Console.WriteLine( “ Arrival Time [{0}]={1}”, i+1, T);
}
AT= SumT /simu;
Console.Read();
}
}
}
Your code is correct but online java compiler taking Console.WriteLine(“”) these semiolon as ASCII code so showing error just you need to replace with correct semicolon like ("").It will work successfully
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.