2. Write a program that emulates rolling a dice. a) Create a roll() function to find the outcome of a 6-side dice roll/ and return the result of a single dice roll. b) Overload the roll() function to find dice rolls of a specific dice size. 1. Accept the dice size as a parameter. 2. Return the result of a single dice roll. c) Overload the roll() function 1. Accept the dice size as a parameter, n. 2. Accept the number of rolls as a second input parameter, r. 3. Accept the third pass-by-reference parameter to calculate the sum of r rolls of an n-side dice. For example, roll (2, 9, sum) will calculate the sum of a 2d9 (2 rolls of a 9-side dice). d) main() handles function calls and output. 1. Output a 6-side dice three times. 2. Output a 10-, 20- and, 30-side dice once time each. 3. Output the sums by calling roll (3, 7, sum), roll (2, 8, sum), and roll (5, 10, sum). 4. Use current time as the seed to generate all the numbers.

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
Answer in C++ Please make sure output shows same as in the picture
2.
Write a program that emulates rolling a dice.
a) Create a roll() function to find the outcome of a 6-side dice roll/
and return the result of a single dice roll.
b) Overload the roll() function to find dice rolls of a specific dice
size.
1. Accept the dice size as a parameter.
2. Return the result of a single dice roll.
c) Overload the roll() function
1. Accept the dice size as a parameter, n.
2. Accept the number of rolls as a second input parameter, r.
3. Accept the third pass-by-reference parameter to calculate the sum
of r rolls of an n-side dice. For example, roll (2, 9, sum) will
calculate the sum of a 2d9 (2 rolls of a 9-side dice).
d) main () handles function calls and output.
1. Output a 6-side dice three times.
2. Output a 10-, 20- and, 30-side dice once time each.
3. Output the sums by calling roll (3, 7, sum), roll (2, 8, sum),
and roll (5, 10, sum).
4. Use current time as the seed to generate all the numbers.
Example Output:
Roll (6): 3
Roll (6): 2
Roll (6): 4
Roll (10): 10
Roll (20): 3
Roll (30): 12
Roll (3d7): 14
Roll (2d8): 7
Roll (5d10): 24
4
MacBook Air
Transcribed Image Text:2. Write a program that emulates rolling a dice. a) Create a roll() function to find the outcome of a 6-side dice roll/ and return the result of a single dice roll. b) Overload the roll() function to find dice rolls of a specific dice size. 1. Accept the dice size as a parameter. 2. Return the result of a single dice roll. c) Overload the roll() function 1. Accept the dice size as a parameter, n. 2. Accept the number of rolls as a second input parameter, r. 3. Accept the third pass-by-reference parameter to calculate the sum of r rolls of an n-side dice. For example, roll (2, 9, sum) will calculate the sum of a 2d9 (2 rolls of a 9-side dice). d) main () handles function calls and output. 1. Output a 6-side dice three times. 2. Output a 10-, 20- and, 30-side dice once time each. 3. Output the sums by calling roll (3, 7, sum), roll (2, 8, sum), and roll (5, 10, sum). 4. Use current time as the seed to generate all the numbers. Example Output: Roll (6): 3 Roll (6): 2 Roll (6): 4 Roll (10): 10 Roll (20): 3 Roll (30): 12 Roll (3d7): 14 Roll (2d8): 7 Roll (5d10): 24 4 MacBook Air
Expert Solution
steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Types of Function
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
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