Starting from:

$25

C++ program that stimulate a lottery

*Overview
Write a program that will simulate a lottery.
*Processing
The main function for this program is pretty basic. It should start by creating two arrays that can hold a maximum of 5 integer elements. One of the arrays will hold the winning lottery numbers, while the other will hold the users selected lottery numbers.As with previous programs, the random number generator will be used. So make sure to seed the random number generator by using srand in main() . Call the getWinners function that is described below to fill the array of winning lottery numbers.Display a title such as "Pick 5 Lottery". Call the getChoices function that is described below to fill the array of user selected lottery numbers. Call the sortArray function two times. One call should sort the array of winning numbers. The other call should should sort the array of user selected numbers. Finally, call the printWinners function that is described below to display the results of the lottery drawing. *The FunctionsFor this program, two functions have been provided. They can be found here: http://faculty.cs.niu.edu/~byrnes/csci240/pgms/assign7.cppThey functions are:bool isDuplicate( int array[], int arraySize, int searchNum )This function will check to see if an integer value has already been placed into an array.It takes three arguments: the array of integers to be searched, the number of values in the array of integers, and the integer value to search for in the array of integers.It returns a boolean value of true if searchNum is found in array or a boolean value of false if searchNum is not in found in array. int getUserNum( int upperBd )This function will get a number between 1 and an upperbound, inclusive.It takes one argument: the integer upperbound.It returns an integer: the user selected value that is between 1 and the passed in upperbound.
Note: before calling this function, execute a cout statement to display a prompt to the user. For example:int num;
cout << "User Choice: ";
num = getUserNum( MAX_NUM ); //where MAX_NUM is a symbolic constant
The following functions are the ones that you are required to write for the program:void getWinners( int array[], int numValues )This function will generate the winning lottery numbers and place them into an array. There will be numValues number of unique winning numbers.It takes two arguments: an array of integers that will be filled with the winning lottery numbers and an integer that represents the number of values to place in the array. It returns nothing.This function will take advantage of the random number generator to generate the winning lottery numbers, which should be in the range of 1 through 10, inclusive. Use a symbolic constant for the upper bound of 10. In a loop that executes exactly numValues number of times, generate a random number between 1 and 10. Check to see if the random number has already been placed into the array by using the isDuplicate function that has been provided. This check should be done in a loop. Once a unique random number has been generated place it into the array.void getChoices( int array[], int numValues )This function will fill an array with the user's selected lottery numbers. There will be numValues number of unique user selected numbers.It takes two arguments: an array of integers that will be filled with the user's numbers and an integer that represents the number of values to place in the array. It returns nothing.This function will be very similar to the getWinners function. However, rather than using the random number generator, it will ask the user to enter the numbers.In a loop that executes exactly numValues number of times, display a prompt to the user to enter a number and get the number by calling the getUserNum function that has been provided. Check to see if the user' number has already been placed into the array by using the isDuplicate function that has been provided. This check should be done in a loop. Once a unique number has been entered place it into the array.void sortArray( int array[], int numValues )This function will use the selection sort algorithm that was presented in lecture to sort the array in ASCENDING order.This function takes two arguments: the first argument is an array of integers that holds the numbers to be sorted, and the second argument is an integer that holds the number of values to be sorted.The function returns nothing.void printWinners( int winArray[], int userArray[], int numValues )This function will display the winning lottery numbers, how many numbers the user matched, and the amount of money that the user won.It takes three arguments: the first an array of integers that holds the winning lottery numbers, the second an array of integers that holds the user selected lottery numbers, and the third argument is an integer that holds the number of values in the arrays. The function returns nothing. Create a local array of 6 doubles to hold the amount of money that is won for a specific number of matches. It should be initialized with the following prize amounts: $0 for 0 matches, $1 for 1 match, $5 for 2 matches, $10 for 3 matches, $20 for 4 matches, and $25 for 5 matches.Display a title such as "The winning numbers are." Follow this with a loop that executes numValues number of times and displays the numbers in the array of winning numbers.Next, check to see how many numbers the user selected match with the winning numbers. This should be done by using nested loops that each execute numValues number of times. The outer loop will be controlled by the subscript for the array of user selected numbers, while the inner loop will be controlled by the subscript for the array of winning numbers. In the inner loop, compare a value from the array of user selected numbers with a value from the array of winning number. If a match is found, increment a counter of the number of matches. Finally, display the number of matches that were found and how much money the user won. If the array of prize amounts was created correctly, the number matches can be used as a subscript to get a prize amount from the array. The prize amount should be displayed with a leading dollar sign and exactly 2 digits after the decimal point. Symbolic ConstantsThis program requires the use of 2 symbolic constants. The first constant should represent the maximum number of picks that the user can make. The value should be 5.The second constant should represent the maximum possible lottery number. The value should be 10.Programming Requirements:1. Each function must have a documentation box explaining:completing program documentation is required. For this assignment, that means that line documentation AND function documentation boxes are needed. In regards to line documentation, there is no need to document every single line, but logical "chunks" of code should be preceded by a line or two that describe what the "chunk" of code does. its nameits use or function: that is, what does it do? What service does it provide to the code that calls it?a list of its arguments briefly describing the meaning and use of each, and in particular whether the function modifies each onethe value returned (if any) or nonenotes on any unusual features, assumptions, techniques, etc. 2. Both of the symbolic constants must be used in the program. 3. Add #include <ctime and #include <cstdlib at the top of the program . 4. Make sure to seed the random number generator by calling the srand function with a value of time(0). This can be done in main before calling the getWinners function. 5. Modify the program to allow the user to choose a Pick 3, Pick 4 or Pick 5 lottery game.The modification should be made in main by displaying a menu to the user and getting their choice. This new value should be passed as the second argument for the getWinners and getChoices functions, and the third argument for the printWinners function. It should also be used in the title that is displayed before the user makes their choice.*OutputThe output will probably be different for you, but it should be similar.Run 1Lottery Game
3. Pick 3
4. Pick 4
5. Pick 5

Which game would you like to play? 3

Pick 3 lottery

User choice 1: 7
User choice 2: 4
User choice 3: 9

The winning numbers are 4 5 9
You matched 2 number(s). You win $5.00
Run 2Lottery Game
3. Pick 3
4. Pick 4
5. Pick 5

Which game would you like to play? 5

Pick 5 lottery

User choice 1: 7
User choice 2: 4
User choice 3: 8
User choice 4: 1
User choice 5: 3

The winning numbers are 1 3 4 7 8
You matched 5 number(s). You win $25.00

More products