Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Help Write a program to simulate a lottery drawing which uses balls that are

ID: 3674052 • Letter: C

Question

C++ Help

Write a program to simulate a lottery drawing which uses balls that are numbered from 1 to 10.

Assume that three balls are drawn at random and the number are unique for each draw. (all 3 numbers must be different). Allow a user to enter the number of lottery drawings to simulate. The program must validate the input. For example, number of drawing can't be negative. The program must not quit in case an input is incorrect.

The program must output the following:

1) What percentage of the time does a draw contain three even numbers in the simulation?

2) What percentage of the time does the number 7 occur in the set of three numbers in the simulation?

3) What percentage of the time does the system draw 1, 2, and 3 (in any order) in the simulation?

OUTPUT (This format MUST be followed)

Enter number of lottery drawings =>10

Draw #1:

   First: 5

Second: 6

   Third: 3

Draw #2:

   First: 3

Second: 2

   Third: 7

Draw #3:

   First:10

Second: 4

   Third: 9

Draw #4:

   First: 1

Second:10

   Third: 5

Draw #5:

   First: 7

Second: 1

   Third: 2

Draw #6:

   First: 9

Second:10

   Third: 6

Draw #7:

   First: 4

Second: 1

   Third: 6

Draw #8:

   First: 8

Second: 2

   Third: 6

Draw #9:

   First: 1

Second: 5

   Third: 8

Draw #10:

   First: 2

Second: 5

   Third: 4

Occurrence of all even:10.00%

   Occurrence of sevens:20.00%

Occurrence of 1-2-3 (any order):0.00%

Explanation / Answer

#include<iostream.h>
#include<conio.h>
#include<stdlib.h>

void main()
{
   int a,b,c,i,j,c7=0, n, c123=0, ce=0;
   double p7,pe,p123;

   cout<<"Enter number of lottery drawings=>";
   cin>>n;

   for(i=1;i<=n;i++)
   {
       cout<<"Draw #"<<i<<endl;
      
       for(j=1;j<4;j++)
       {
           a=rand()%10+1;
           b=rand()%10+1;
           c=rand()%10+1;
           cout<<"First:"<<a<<endl;
          

cout<<"Second:"<<a<<endl;
           cout<<"Third:"<<a<<endl;
       }
       if(a==7 || b==7 || c==7)
       {
           c7++;
       }

       if(a==1 && b==2 && c==3)
       {
           c123++;
       }

       if(a%2==0 || b%2==0 || c%2==0)
       {
           ce++;
       }
   }

   p7=c7*100/(n*3);
   pe=ce*100/(n*3);
   p123=c123*100/n;

   cout<<"Occurrence of all

even:"<<pe<<"%"<<endl;

   cout<<"Occurrence of

sevens:"<<p7<<"%"<<endl;

   cout<<"Occurrence of 1-2-3 (any

order)"<<p123<<"%"<<endl;
   getch();
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote