Write a program in C++ to simulate a lottery drawing that uses balls numbered fr
ID: 3759982 • Letter: W
Question
Write a program in C++ to simulate a lottery drawing that uses balls numbered from 1 to 10. Assume that five balls are drawn at random. All five balls for each drawing are unique. Allow the user to enter the number of lottery drawings to simulate.
Validate the input of lottery drawings.
What percentage of the time does the result contain five even numbers in the simulation?
What percentage of the time does the number 7 occur in the five numbers in the simulation?
What percentage of the time do the numbers 1, 2, 3, 4 and 5 occur in simulation (in any order)?
Use at least three functions:
1)Function to get number of lottery drawings and validate
2)Function to generate unique random numbers (no duplicate numbers in a roll)
3)Function to calculate percentages The program should run as long as user would like.
Explanation / Answer
view sourceprint?
01
void Lottery(int x)
02
{
03
int random_integer, user_input, lowest=1, highest=10, range=(highest-lowest)+1;
04
cout << "How many times would you like me to simulate the lottery drawing: ";
05
cin >> user_input;
06
07
for (int index = 0; index < user_input; index++)
08
{
09
random_integer = lowest + int (range*rand());
10
(RAND_MAX +1);
11
cout << random_integer << endl;
12
}
13
14
15
/*cout << " Operations " << endl;
16
cout << "1. Temperature Conversion Celsius to Fahrenheit" << endl;
17
cout << "2. Salary Calculator" << endl;
18
cout << "3. Print A Hollow Square" << endl;
19
cout << "4. Estimate The Value Of Pi" << endl;
20
cout << "5. Lottery Drawing" << endl;
21
cout << "6. Exit Program " << endl;
22
23
cin >> program; */
24
return;
25
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.