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 :)
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 :)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps