Question: Emulate the rolling of dice. a) Write a roll function which accepts the number of dice sides as input and returns the result of a
Emulate the rolling of dice.
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.
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.
Example Output (input in bold italics)
6-sided: 6
12-sided: 7
20-sided: 16
3d7: 11
2d8: 12
4d5: 7
c++, write on atom software.
Step by Step Solution
3.40 Rating (150 Votes )
There are 3 Steps involved in it
include include for rand include for time using namespace std method to roll a die with sid... View full answer
Get step-by-step solutions from verified subject matter experts
