Great Deal! Get Instant \$10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

# Problem: You are assigned to program a game that simulates a monthly lottery. Every month, seven distinct random integers between 1 to 20 (inclusive) are drawn. Using a vector, do the followings:...

Problem: You are assigned to program a game that simulates a monthly lottery. Every month, seven distinct random integers between 1 to 20 (inclusive) are drawn. Using a vector, do the followings:

Generates seven distinct random numbers between 1 and 20 (inclusive) and stores them in a vector.Sorts the vector containing the lottery numbers.Prompts the player to select seven distinct integers between 1 and 20 and stores the numbers in the vector.Determines whether the player guessed the lottery numbers correctly. If the player guessed the lottery numbers correctly, it outputs the right message.Your program should allow a player to play the game as many times as the player wants to play. Before each play, generate a new set of lottery numbers.
Answered Same Day Apr 09, 2020

## Solution

Ujjawal answered on Apr 12 2020
#include #include #include #include #include #include #include using namespace std;
**
*
* Generates 7 distinct random numbers
* *
void GenerateOrGetLotteryNumbers(vecto
int>& randomLotteryNumbers) {
cout
"Generating random numbers..."
endl;
for (int i = 0; i < 7; ++i) {
srand(time(NULL));

generates a random number between 1 and 20 but not including 50
int randomLotteryNumber = rand() % 20 + 1;
vecto
int>::iterator itr = find(randomLotteryNumbers.begin(),
randomLotteryNumbers.end(), randomLotteryNumber);
if (itr != randomLotteryNumbers.end()) {
i--;
if number is already present, then generate...
SOLUTION.PDF