
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Question
The

Transcribed Image Text:3. Create an application for generating lottery tickets of random numbers. Each lottery ticket has a fixed number of slots
with each slot having a number selected within a given range. The main function is responsible for obtaining the number
of slots as well as the range of numbers from the end user. Define a lotto function that accepts two parameters. The first
should be the upper range for the available 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. Also create a display function which 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 (based on the given range), shuffles these values using the random_shuffle()
function, and then retrieves the number of values needed from the beginning of the vector. The random_shuffle()
function requires two parameters that specify the beginning and ending elements and will randomly rearrange the values
within these elements. Use the .begin() and .end() methods to define this range. For example, when the vector
allNumbers contains all the values between 1 and 51, the values can be rearranged (shuffled) using:
random_shuffle(alINumbers.begin(),alINumbers.end());
The sort() function can be used to order the values stored in the result vector. The sort() function requires two
parameters that specify the range, using the same syntax as the random_shuffle() function. Both random_shuffle() and
sort() are defined in the <algorithm> library. Please see http://www.cplusplus.com/reference/algorithm/¤ to learn more
about the random_shuffle and sort algorithms.
Еxample run:
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 tícket? (Y or N): n
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images

Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Don't give me AI generated answer or plagiarised answer. If I see these things I'll give you multiple downvotes and will report immediately.arrow_forwardPlease comment each C statement in C program and write the output.arrow_forwardHello good afternoon, This is my first time using Bartleby, I am super slow in computer science and I am wondering if you please can help me to be very specific and explanative as possible with the following problem. to be honest, I don't even know how to start. Write a C++ program that computes a student’s grade for an assignment as a percentage given the student’s score and total points. The final score must be rounded up to the nearest whole value using the ceil function in the header file. You must also display the floating-point result of up to 5 decimal places. The input to the program must come from a file containing a single line with the score and total separated by a space. In addition, you must print to the console “Excellent” if the grade is greater than or equal to 90, “Well Done” if the grade is less than 90 and greater than or equal to 80, “Good” if the grade is less than 80 and greater than or equal to 70, “Need Improvement” if the grade is less than 70 and greater than…arrow_forward
- I am trying to write this program and I got stuck on page two. Please help me write this.arrow_forwardThe heart of programming is using if statements and looping. Search online to find differences in Python branching (decision) and repetition (looping) statements compared to other languages such as C++ and Java. Share your findings and your experiences learning selection and loops last week and this week of learning Python control structures. Give your citations.arrow_forwardi need help with a practice question in c++arrow_forward
- In C++ create this basic program please, but avoid using many external libraries, manipulators, and advanced other materialsarrow_forwardThis is very helpful thank you. If possible can you please show me how to make the function with the original parameters C++arrow_forward4. Create a function in the C language that takes an integer as the parameter and returns the count of 0 in that number. Also, test your function inside the main function.arrow_forward
- Haskellarrow_forwardNeed help figuring out this program and typing it in c++.arrow_forwardPlease I need to answers these questions in C++. Thank you. Question: Does the if-else if structure offer any advantages over nested if statements? Choose the correct answer from below: A. It helps keep the code understandable and readable on the screen or on paper B. It does away with the need of a trailing else C. It can handle logic that nested if statements cannot handle D. Neither has an advantage over the other E. The text did not discuss this topic Question: What is the purpose of a trailing else in an if-else if ladder structure? Choose the correct answer from below: A. It handles the "none of the above" situation in the problem B. Two of the other answers are correct C. It is often used to catch errors D. It deals with the most complex boolean expression E. It is the only part of the ladder that is not optionalarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education

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)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON

Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON

C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON

Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning

Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education