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 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 match.
For example:
Lottery array: 7 4 9 1 3
User array : 4 2 9 7 3
There are two matching digits (elements 2 and 4).
The program should display the random numbers stored in lottery array and the numbers chosen by the user and then give the number of matching digits. If all digits match, display a message proclaiming the user a grand prize winner.
#include<iostream>
#define ARRAY_SIZE 5
#define MAX_RANGE 10
using namespace std;
int main(){
int arr[ARRAY_SIZE];
int lottery[ARRAY_SIZE];
for(int i=0;i<ARRAY_SIZE;i++)
lottery[i]=rand()%MAX_RANGE;
cout<<"Enter "<<ARRAY_SIZE<<" elements: ";
for(int i=0;i<ARRAY_SIZE;i++)
cin>>arr[i];
int count=0;
for(int i=0;i<ARRAY_SIZE;i++)
if(arr[i]==lottery[i])
count++;
cout<<"Lottery :";
for(int i=0;i<ARRAY_SIZE;i++)
cout<<lottery[i]<<" ";
cout<<endl;
cout<<"User :";
for(int i=0;i<ARRAY_SIZE;i++)
cout<<arr[i]<<" ";
cout<<endl;
if(count==ARRAY_SIZE){
cout<<"Congratulations... grand prize winner";
}
else{
cout<<"There are "<<count<<" matching digits" ;
}
}
Write a C++ program that simulates a lottery game. Your program should use functions and arrays....
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...
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...
In C... Write a program to simulate a pick-5 lottery game. Your program must generate and store 5 distinct random numbers between 1 and 9 (inclusive) in an array. The program prompts the user for: an integer random seed five distinct integers between 1 and 9 (which are stored in another array) The program then compares the two arrays to determine if they are identical. If the two arrays are identical, then the user wins the game. otherwise the program...
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...
COP2221 - Intermediate C++ Programming Module #6 Assignment One 20 points This assignment refers to Learning Outcome #2: Create and utilize arrays to store lists of related data Programming Problem You have been hired to create a C++ program to simulate the lottery. Your program allows users to see how often their lottery number choices match a randomly generated set of numbers used to pick lottery winners. The company, "How Lucky Are You?, Inc." wants a modular, professional and user-friendly...
C only (not C++) Write a C program that simulates a game. There are two players (called Player1 and Player2). At the start of the game, each player chooses a number from 1 to 10 (cannot be the same). Then, the program will generate a random number from 1 to 10. The game ends when either Player1 or Player2 hits the number generated by the program. Display the winning message for the winner. Example output: Player 1: 6 Player 2:...
Lottery Game (15 Numbers). Design and implement a C++ program that generates 15 random non-repeating positive integer numbers from 1 to 999 (lottery numbers) and takes a single input from the user and checks the input against the 15 lottery numbers. The user wins if her/his input matches one of the lottery numbers. Your implementation must have a level of modularity (using functions) Functions you need to implement: Define function initialize() that takes array lotterNumbers[] as a parameter and assigns...
Please help with this, and leave comments explainging the code you wrote, thank you for your help 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...
c++ PROGRAM DESCRIPTION: In this assignment, you will be creating a memory matching game in C++. In this game, the user will need to match up the pairs symbols A,B,C,D,E on a 4x4 array. For example, the array could be initialized like the following: In this case, X represents an empty slot. The goal is for the user to match the A to the A, the B to the B, etc, until all pairs are matched up to win the...
I HAVE A PROBLE WITH THIS JAVA PROBLEM CAN ANYONE HELP ME PLEASE. Exercise 2 Write a program that simulates the Texas Powerball lottery. You will have to do research to find out how many numbers are drawn, and what the range(s) of the numbers are. For this exercise you need to create a class called "Powerbali", which exposes a public function called play'. This function accepts several parameters , which represent the individual numbers the player wants to play....