Create an application for generating lottery tickets of random numbers. Each lottery ticket has a fixed count of numbers to be played with each number selected being within a given range.  For example, when the range of numbers is 1 through 100, and 5 numbers are to be played, the lottery ticket will be composed of 5 unique values between 1 and 100.  The values are selected at random. The main function is responsible for obtaining the upper range of the numbers and the count of numbers to be played from the end user.  The count of numbers must be less than the upper range.  The main function will call the generateLotto function to generate the lottery ticket and then call the displayTicket function to display the resulting lottery ticket.  Any number of lottery tickets may be generated. The generateLotto function should accept two parameters. The first should be the upper range for the numbers while the second parameter represents a count of the numbers to be played. For example, lotto(51, 6) will select 6 numbers at random between 1 and 51 (inclusive.) The function should return a vector of unique integer values in sorted order.   The displayTicket function accepts a vector of integers and displays the vector. Hints: Although the standard library defines a rand() function for generating random numbers, the function may produce duplicate numbers and hence, is not suitable for this application. To ensure that unique values are generated, create a vector that contains all possible values (1 through the given upper range) and then shuffle these values using the random_shuffle() function.  This will result in a vector of numbers between 1 and the upper range in random order.  From this vector, select the required number of values from the beginning of the vector, adding these values to the result vector.  Lastly, use the sort() function to sort the result vector. The random_shuffle() and sort() functions require two parameters that specify the beginning and ending elements on which to operate.  To specify the beginning and ending of the vector, the begin() and end() methods of the vector class can be used.  For example, when the vector allNumbers contains all the values between 1 and 51, the values within the vector can be rearranged (shuffled) using:      random_shuffle(allNumbers.begin(),allNumbers.end()); I HAVE ATTACHED AND EXAMPLE DISPLAY!

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Create an application for generating lottery tickets of random numbers. Each lottery ticket has a fixed count of numbers to be played with each number selected being within a given range.  For example, when the range of numbers is 1 through 100, and 5 numbers are to be played, the lottery ticket will be composed of 5 unique values between 1 and 100.  The values are selected at random.

The main function is responsible for obtaining the upper range of the numbers and the count of numbers to be played from the end user.  The count of numbers must be less than the upper range.  The main function will call the generateLotto function to generate the lottery ticket and then call the displayTicket function to display the resulting lottery ticket.  Any number of lottery tickets may be generated.

The generateLotto function should accept two parameters. The first should be the upper range for the numbers while the second parameter represents a count of the numbers to be played. For example, lotto(51, 6) will select 6 numbers at random between 1 and 51 (inclusive.) The function should return a vector of unique integer values in sorted order.  

The displayTicket function accepts a vector of integers and displays the vector.

Hints: Although the standard library defines a rand() function for generating random numbers, the function may produce duplicate numbers and hence, is not suitable for this application. To ensure that unique values are generated, create a vector that contains all possible values (1 through the given upper range) and then shuffle these values using the random_shuffle() function.  This will result in a vector of numbers between 1 and the upper range in random order.  From this vector, select the required number of values from the beginning of the vector, adding these values to the result vector.  Lastly, use the sort() function to sort the result vector.

The random_shuffle() and sort() functions require two parameters that specify the beginning and ending elements on which to operate.  To specify the beginning and ending of the vector, the begin() and end() methods of the vector class can be used.  For example, when the vector allNumbers contains all the values between 1 and 51, the values within the vector can be rearranged (shuffled) using:

     random_shuffle(allNumbers.begin(),allNumbers.end());

I HAVE ATTACHED AND EXAMPLE DISPLAY!

Enter the highest number: 51
How many numbers should be generated? 6
Your randomly generated ticket: 1 2 10 13 28 50
Do you want to generate another ticket? (Y or N): y
Enter the highest number: 51
How many numbers should be generated? 6
Your randomly generated ticket: 2 24 30 35 37 39
Do you want to generate another ticket? (Y or N) : y
Enter the highest number: 21
How many numbers should be generated? 4
Your randomly generated ticket: 6 10 11 14
Do you want to generate another ticket? (Y or N): n
Transcribed Image Text:Enter the highest number: 51 How many numbers should be generated? 6 Your randomly generated ticket: 1 2 10 13 28 50 Do you want to generate another ticket? (Y or N): y Enter the highest number: 51 How many numbers should be generated? 6 Your randomly generated ticket: 2 24 30 35 37 39 Do you want to generate another ticket? (Y or N) : y Enter the highest number: 21 How many numbers should be generated? 4 Your randomly generated ticket: 6 10 11 14 Do you want to generate another ticket? (Y or N): n
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education