Write a C++ program that simulates a lottery. The user will select 5 numbers 0 through 9 and put this in an array. Then these user numbers are compared to the random numbers the computer generated. The program will display both the computer random number and below the user selected numbers. The program will tell the user how many matches are made. If the user guesses all five you let them know they are the grand winner.
Here is the required starting code below. You are to finish the project by completing the required functions.
HINT Just copy and past the following code and partially done functions to your project and start from there.
// Lottery Application
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <ctime>
using namespace std;
const int ARRAY_SIZE = 5;
const int MAX_RANGE = 10;
// Function prototypes
void generateNumbers(int [], int);
void getUser(int [], int);
int findMatches(int [], int [], int);
void displayValues(int [], int [], int);
int main()
{
int lottery[ARRAY_SIZE]; // Lottery numbers
int user[ARRAY_SIZE]; // User's numbers
int numMatches; // Number of matches
// Generate the random lottery numbers.
generateNumbers(lottery, ARRAY_SIZE);
// Get the user's numbers.
cout << "Enter five numbers 0 through 9 for lottery numbers" << endl;
getUser(user, ARRAY_SIZE);
// Get the number of matching numbers.
numMatches = findMatches(lottery, user, ARRAY_SIZE);
// Display the lottery and user numbers.
displayValues(lottery, user, ARRAY_SIZE);
// Display the number of matching numbers.
cout << "You matched " << numMatches << " numbers.\n";
// Determine whether the user won the grand prize.
if (numMatches == 5)
cout << "Congratulations! You're the grand prize winner!!\n";
return 0;
} // end main
//**********************************************
// Function generateNumbers.
// This function generates random numbers
// and stores them in the lottery array.
//**********************************************
void generateNumbers(int lottery[], int size)
{
// Seed the random number generator.
srand(time(NULL));
// Generate the random numbers.
cout << "normally do not see this, added to help debug" << endl;
for (int i = 0; i < size; i++)
{
lottery[i] = 0 + rand() % MAX_RANGE;
cout << " lottery[" << i << "] = " << lottery[i] << " ";
//added to help do checking normally do not see this <wink>
}
cout << endl << endl;
} //end generateNumbers
//**********************************************
// Function getUser.
// This function gets the user's lottery picks.
//**********************************************
void getUser(int user[], int size)
{
// Get the user's picks.
}
//**********************************************
// Function findMatches.
// This function finds the number of the user's
// values that match the lottery numbers. The
// number of matches is returned.
//**********************************************
int findMatches(int lottery[], int user[], int size)
{
}
//**********************************************
// Function displayValues. *
// This function displays the values in the *
// lottery array and the user array. *
//**********************************************
void displayValues(int lottery[], int user[], int size)
{
}
/* proof
normally do not see this, added to help debug
lottery[0] = 7 lottery[1] = 0 lottery[2] = 9 lottery[3] = 5 lottery[4] = 6
Enter five numbers 0 through 9 for lottery numbers
Number 1: 4
Number 2: 0
Number 3: 9
Number 4: 5
Number 5: 2
Lottery numbers:
7 0 9 5 6
Your numbers:
4 0 9 5 2
You matched 3 numbers.
///////////////////////
normally do not see this, added to help debug
lottery[0] = 9 lottery[1] = 5 lottery[2] = 6 lottery[3] = 0 lottery[4] = 9
Enter five numbers 0 through 9 for lottery numbers
Number 1: 9
Number 2: 5
Number 3: 6
Number 4: 0
Number 5: 9
Lottery numbers:
9 5 6 0 9
Your numbers:
9 5 6 0 9
You matched 5 numbers.
Congratulations! You're the grand prize winner!!
*/
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <ctime>
using namespace std;
const int ARRAY_SIZE = 5;
const int MAX_RANGE = 10;
// Function prototypes
void generateNumbers(int [], int);
void getUser(int [], int);
int findMatches(int [], int [], int);
void displayValues(int [], int [], int);
int main()
{
int lottery[ARRAY_SIZE]; // Lottery numbers
int user[ARRAY_SIZE]; // User's numbers
int numMatches; // Number of matches
// Generate the random lottery numbers.
generateNumbers(lottery, ARRAY_SIZE);
// Get the user's numbers.
cout << "Enter five numbers 0 through 9 for lottery numbers" << endl;
getUser(user, ARRAY_SIZE);
// Get the number of matching numbers.
numMatches = findMatches(lottery, user, ARRAY_SIZE);
// Display the lottery and user numbers.
displayValues(lottery, user, ARRAY_SIZE);
// Display the number of matching numbers.
cout << "You matched " << numMatches << " numbers.\n";
// Determine whether the user won the grand prize.
if (numMatches == 5)
cout << "Congratulations! You're the grand prize winner!!\n";
return 0;
} // end main
/**********************************************
// Function generateNumbers.
// This function generates random numbers
// and stores them in the lottery array.
//**********************************************/
void generateNumbers(int lottery[], int size)
{
// Seed the random number generator.
srand(time(NULL));
// Generate the random numbers.
cout << "normally do not see this, added to help debug" << endl;
for (int i = 0; i < size; i++)
{
lottery[i] = 0 + rand() % MAX_RANGE;
}
cout << endl << endl;
} //end generateNumbers
//**********************************************
// Function getUser.
// This function gets the user's lottery picks.
//**********************************************
void getUser(int user[], int size)
{
for(int i = 0; i < size; i++)
{
cout << "Number " << (i + 1) << ": ";
cin >> user[i];
}
}
//**********************************************
// Function findMatches.
// This function finds the number of the user's
// values that match the lottery numbers. The
// number of matches is returned.
//**********************************************
int findMatches(int lottery[], int user[], int size)
{
int matches = 0;
for(int i = 0; i < size; i++)
{
if(user[i] == lottery[i])
matches++;
}
return matches;
}
//**********************************************
// Function displayValues. *
// This function displays the values in the *
// lottery array and the user array. *
//**********************************************
void displayValues(int lottery[], int user[], int size)
{
// displaying the lottery numbers
cout << endl << "Lottery numbers:" << endl;
for(int i = 0; i < size; i++)
{
cout << lottery[i] << " ";
}
cout << endl;
// displaying the user numbers
cout << "Your numbers:" << endl;
for(int i = 0; i < size; i++)
{
cout << user[i] << " ";
}
cout << endl << endl;
}
****************************************************************** SCREENSHOT *********************************************************


Write a C++ program that simulates a lottery. The user will select 5 numbers 0 through...
Write a C++ program that simulates a lottery game. Your program should use functions and arrays. Define two global constants: - ARRAY_SIZE that stores the number of drawn numbers (for example 5) -MAX_RANGE that stores the highest value of the numbers ( for example 9 ) The program will use an array of five integers named lottery, and should generate a random number in the range of 0 through 9 for each element of the array. The user should enter...
Write a Lottery class that simulates a 6-number lottery (e.g. "Lotto"). The class should have an array of six integers named lotteryNumbers, and another array of six integers named userLotteryPicks. The class' constructor should use the Random class to generate a unique random number in the range of 1 to 60 for each of the 6 elements in the lotteryNumbers array. Thus, there should be a loop that keeps generating random numbers until all 6 numbers are unique. The Lottery class...
I need help with coding with c++. I need to make a lottery program where you enter in 5 numbers from 0-9 and the program will generate 5 random numbers 0-9 to represent the lottery numbers. I'm almost done, but the output isn't exactly what I want. It works fine, but the format should look like this: lottery array: 7 4 9 1 3 user array: 4 2 9 7 p.s. I also need to count how many matching numbers...
Modify PartTwo.cpp so that it is uses a vector, named vect, instead of an array. PartTwo.cpp Is posted here: // This program reads data from a file into an array. Then, it // asks the user for a number. It then compares the user number to // each element in the array, displays the array element if it is larger. // After looking at entire array, it displays the number of elements in the array larger // than the user...
Write a C++ program that simulates playing the Powerball game. The program will generate random numbers to simulate the lottery terminal generated numbers for white balls and red Powerball. The user will have the option to self-pick the numbers for the balls or let the computer randomly generate them. Set the Grand Prize to $1,000,000,000.00 in the program. Project Specifications Input for this project: Game mode choice – self pick or auto pick Five numbers between 1 and 69 for...
Using C++ create a lotto program Lottery Design a program that simulates a lottery. Requirements: The program should have an array of 5 integers named lottery and should generate a random number in the range of 1 through 99 for each element of the array. The user should enter five digits, which should be stored in an integer array named user. The program is to compare the corresponding elements in the two arrays and keep a count of the digits that...
Hello, I am working on a C++ pick 5 lottery game that gives you the option to play over and over. I have everything working right except that every time the game runs it generates the same winning numbers. I know this is an srand or rand problem, (at least I think it is), but I can't figure out what my mistake is. I've tried moving srand out of the loop, but I'm still getting the same random numbers every...
// Program takes 5 numbers from a user (from console), stores them into an // array, and then prints them to the screen (on the same line). // Add code to complete this program. You only need to add code where indicated // by "ADD HERE". #include <iostream> using namespace std; int main() { const int SIZE = 5; // size of array // ADD HERE - create an array of integers that will hold 5 integers. cout << "please...
Remove srand(time(NULL)); from this C++ code so that it still finds random numbers correctly. Then, Write a program that adds the following to the fixed code. • Add a function that will use the BubbleSort method to put the numbers in ascending order. – Send the function the array. – Send the function the size of the array. – The sorted array will be sent back through the parameter list, so the data type of the function will be void....
in a c++ visual studio 2017 ...Write a program that simulates a lottery. The program should have an array of five integers named lottery and should generate a random number in the range 0 through 9 for each element in the array. The user should enter five digits, which should be stored in an integer array named user. The program is to compare the corresponding element in the two arrays and keep a count of the digits that match. For...