/*Qusetion:
3 dies are rolled
i)Find the Sample space
ii)Find the probability of an event that have sum of dots in
3 die is more than 10 */
#include <iostream>
#include <conio>
#include <stdlib>
void main()
{
int i,j,k,n;
float z;
float l=0.0; /*l has a data type float mean l store floating value like...1.0,2.3...... and here it count the
event which grater than 10;*/
float d=0.0;/*d also has a data type float and here use to count totall sample spaces(All possible cases which
occure when 3 dies are rolled) */
while(1)
{
cout<<"\t\t~~~~~~~~~~~~~~~~~~~~~~~\n";
cout<<"\t\tWELCOM TO MAIN MENU\n";
cout<<"\t\tWHAT DO YOU WANT \n\n";
cout<<"\t\t~~~~~~~~~~~~~~~~~~~~~~~\n\n";
cout<<"********************************************************************************\n";
cout<<"\tPRESS 1 for sample spaces\t";
cout<<endl<<endl;
cout<<"\tPRESS 2 for An Event that has sum of 3 dots of die is grater than 10 \t ";
cout<<endl;
cout<<"\tPRESS 3 for Check probability of An Event that has sum of 3 dots of"<<endl;
cout<<" Dies are grater than 10\t";
cout<<endl<<endl;
cout<<"\tPRESS 4 for Exit from the Main Menu\t ";
cout<<endl<<endl;
cout<<"********************************************************************************\n";
cin>>n;
switch(n)
{
case 1:
cout<<"The sample spaces when 3 dies rolled are\n";
for(i=1;i<=6;i++) /*For first die D1={1,2,3,4,5,6}*/
{
for(j=1;j<=6;j++) /*For 2nd die D2={1,2,3,4,5,6}*/
{
for(k=1;k<=6;k++) /*For 3rd die D3={1,2,3,4,5,6}*/
{
cout<<i<<j<<k<<endl;
d++;
}}
/*d++ mean here it increament its value when one sample dispalay
d=1,for 2nd sample d=2,and so d=1,2,3,4,5,.....................216*/
} cout<<"The total sample spaces is=\t"<<d<<endl;
break;
case 2:
cout<<"The sample space which is grater than 10 is\n";
for(i=1;i<=6;i++) /*For first die D1={1,2,3,4,5,6}*/
{
for(j=1;j<=6;j++) /*For 2nd die D2={1,2,3,4,5,6}*/
{
for(k=1;k<=6;k++) /*For 3rd die D3={1,2,3,4,5,6}*/
{
if(i+j+k>10)/*if is a conditional statemaent which is used here that sum of 3 dots of die is grater than 10*/
{
cout<<i<<j<<k<<endl;
l++;
}}} } cout<<"The sample spaces that have sum of 3 dots has grater than 10 Are\t"<<l<<endl;
break;
case 3:
z=l/d;
cout<<"The probability of P(A):\t"<<z<<endl;
break;
case 4:
exit(0);
break;
} }
getch();}
0 comments:
Post a Comment