could somebody please help me with this C++ program? Create a program that gener
ID: 3834851 • Letter: C
Question
could somebody please help me with this C++ program?
Create a program that generates random lottery numbers. Your program should be able to generate lottery numbers on request of lengths 3, 4, 5, 6, or 6 + a kicker value (A kicker value is a side number, usually from a greatly reduced range, for example, 6 values would be in the range of 1 to 40 and the kicker would be in the range of 1 to 7 Your program should A. Define a function that takes a high and low value and returns a random value in the given range B. Loop and let a user generate lottery numbers until they indicate they are done C. Provide a menu of the following actions 1. Allow a user to input the range of possible values for the basic lottery numbers (low and high values, all must be positive values) 2. Allow a user to input the range of possible values for the kicker numbers (low and high values, all must be positive values) 3. Allow a user to ask for lottery numbers of length 3, 4, 5, 6 or 6 + a kicker value 4. Allow a user to ask for 1 or more numbers of a particular length, for example, a user could ask for 2 lottery numbers of length 3, 1 lottery number of length 4, etc. 5. Output lottery numbers with a space between the digits, for example, a 6 digit number with a kicker: 12 24 45 17 4 7 kicker 5 D. Provide any necessary error handling, for example, only positive values should be entered.Explanation / Answer
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
void generateLotteryNumbers (int lotteryNumbers[]);
void main()
{
int lotteryNumbers[5];
srand (time(0));
generateLotteryNumbers (lotteryNumbers);
cout << lotteryNumbers << endl;
}
//This function will generate five lottery numbers
#include <iostream>
using namespace std;
void generateLotteryNumbers (int lotteryNumbers[])
{
const int SIZE = 5;
int randomNumbers;
int index = 0;
int number;
bool used;
for (int index = 0; index < SIZE; index++)
{
int number = rand()% 50 + 1;
do
{
used = false;
for(int index = 0; index < SIZE; index++)
{
if( number == randomNumbers[index] )
used = true;
}
}while(used);
randomNumbers[index] = number;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.