[SOLVED] Winning Digits – Lottery C++

$25

File Name: Winning_Digits_-_Lottery_C++.zip
File Size: 263.76 KB

SKU: [Solved] winning Digits Category: Tag:
5/5 - (1 vote)

Write a c++ program that simulates a lottery. The program should have an array of 5 integers namedwinningDigits, with a randomly generated number in the range of 0 through 9 for each element in the array. The program should ask the user to enter 5 digits and should store them in a second integer array namedplayer. The program must compare the corresponding elements in the two arrays and count how many digits match. For example, the following shows the winningDigits array and the player array with sample numbers stored in each. There are two matching digits, elements index 2 and index 4.

WinningDigits: 7 4 9 1 3
Enter 5 integers separate with space:4 2 9 7 3

WinningDigits: 7 4 9 1 3
Player digits: 4 2 9 7 3
Matching elements: 2 4
Numbers appearing in both arrays: 3 4 9 7

To make sure your code works, display the contents of the winningDigits array before asking the user to enter their numbers.
Note:Both the winningDigits and the player arraysmay not haveduplicatenumbers.
Enhance the program to print the numbers that appeared in both arrays. In our example, order not important:
You maynot use globalvariables, except forMAX_SIZE=5. Required functions:

voidrandomArray(int arr1[], int &elements1): fills arr with random numbers.
voidplayerArray(int arr2[], int &elements2): fills arr2 with user entered numbers.

boolisAlreadyIn(int arr[],int elements, int n): returns true if n is already in arr1.

voiddisplayArray( (int arr[], int elements): prints the elements of the array
voidshowMatching(int arr1[], int arr2[]): displayes the index/s of matching elements. There may not be any matching elements.
voidnumbersInBoth(int arr1[], int arr2[]): displayes the numbers that appear in both arrays.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] Winning Digits – Lottery C++
$25