Modify the code below to support specifying additional dice typein addition to a 6 sided dice.
For example, the program could support six-sided, eight-sided,10 sided die.
HINTS: You will need to
- Create an enum type for the dice type and values
- Modify the parameter passing of some of the functions to passthe die type
- Adjust the actual code that simulates the die roll to generatea range of values appropriate to the user's selected die type.
Think about parameter passing. It is possible to do this with avery few modifications to the program.
//Program: Roll dice
#include
#include
#include
using namespace std;
int rollDice(int num);
int main()
{
cout << \"The number of times the dice are rolled to \"
<< \"get the sum 10 = \" << rollDice(10) <cout << \"The number of times the dice are rolled to \"
<< \"get the sum 6 = \" << rollDice(6) << endl;
return 0;
}
int rollDice(int num)
{
int die1;
int die2;
int sum;
int rollCount = 0;
srand(time(0));
do
{
die1 = rand() % 6 + 1;
die2 = rand() % 6 + 1;
sum = die1 + die2;
rollCount++;
}
while (sum != num);
return rollCount;
}