Write a program 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:
Function to get number of lottery drawings and validate
Function to generate unique random numbers (no duplicate numbers in a roll)
Function to calculate percentages
Your program should run as long as user would like.
SAMPLE OUTPUT:
Enter number of lottery drawings =>-4
Number of lottery drawings must be greater than 0!
Please re-enter number of lottery drawings =>5
Roll #1
5 9 6 4 10
Roll #2
10 9 7 3 2
Roll #3
6 5 3 1 4
Roll #4
5 6 2 4 3
Roll #5
10 1 9 8 4
Percentages of all even = 0%
Percentages of sevens = 20%
Percentages of all 1-2-3-4-5 order = 0%
Another round for the lottery? Type 1 for yes, any other number for no: 1
Enter number of lottery drawings =>3
Roll #1
4 10 6 9 7
Roll #2
1 5 8 9 3
Roll #3
2 10 7 6 3
Percentages of all even = 0%
Percentages of sevens = 66.6667%
Percentages of all 1-2-3-4-5 order = 0%
Another round for the lottery? Type 1 for yes, any other number for no: 2
I've actually doing something like this right now. It's real easy. I'm busy right now, but as soon as I finish I can have it done in an hour. - probably tomorrow morning. i've programmed C/C++ for 10 years
$29 USD en 1 día
5,0 (35 comentarios)
5,6
5,6
5 freelancers están ofertando un promedio de $30 USD por este trabajo