//Write a simulation program
//to find the probability of
//getting 5 throwing a dice
//100 times
class dice2
{
public static void main(String args[])
{
int i,n,c=0;
double r,p;
for(i=1;i<=100;i++)
{
r=Math.random();
n=(int)(r*6)+1;
if(n==5) c++;
}
p=c/100.0;
System.out.println("P(5)="+p);
}
}
//to find the probability of
//getting 5 throwing a dice
//100 times
class dice2
{
public static void main(String args[])
{
int i,n,c=0;
double r,p;
for(i=1;i<=100;i++)
{
r=Math.random();
n=(int)(r*6)+1;
if(n==5) c++;
}
p=c/100.0;
System.out.println("P(5)="+p);
}
}
No comments:
Post a Comment