Emulate the rolling of dice. [ C++ ] a) Write a roll function which accepts the number of dice sides as input   and returns the result of a random dice roll of the specified size. b) Overload the roll function to accept the number of rolls as a second  input parameter. The overloaded function should return a random value  which is the sum of r rolls of an n sided die.  For example 2d9 is 2 rolls of a 9-sided die. c) Test the first function with various dice sizes (see output). d) Test the second function with various values (see output). e) The program should generate new random values every time it runs. Note that dice values start at 1. Comments would also be greatly appreciated to help in explanation, thank you :)

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 44SA
icon
Related questions
Question
100%

Emulate the rolling of dice. [ C++ ]


a) Write a roll function which accepts the number of dice sides as input 
 and returns the result of a random dice roll of the specified size.
b) Overload the roll function to accept the number of rolls as a second
 input parameter. The overloaded function should return a random value
 which is the sum of r rolls of an n sided die.
 For example 2d9 is 2 rolls of a 9-sided die.
c) Test the first function with various dice sizes (see output).
d) Test the second function with various values (see output).
e) The program should generate new random values every time it runs.

Note that dice values start at 1.

Comments would also be greatly appreciated to help in explanation, thank you :)

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Functions
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr