Having some trouble on the last part of this question. I was able to make a die that rolls randomly and outputs the number. I was able to make 2 die roll randomly and output the sum of both. I was also able to let the user decide how many sides the die would have and output the random side it lands on. Now, I need to let the user choose the number of sides AND the number of times it is rolled. I then need to get the sum of all the numbers that were rolled. Here is what I have so far
#include <iostream>
#include <cstdlib>
#include <time.h>
usingnamespace std;
int oneDie() {
int rollOneDie;
int min = 1;
int max = 6;
rollOneDie = rand() % (max - min + 1) + min;
return rollOneDie;
}
int twoDie() {
int rollOne;
int rollSecond;
int min = 1;
int max = 6;
rollOne = rand() % (max - min + 1) + min;
rollSecond = rand() % (max - min + 1) + min;
int rollTotal = rollOne + rollSecond;
return rollTotal;
}
int userSides() {
int userRoll;
int min = 1;
int max;
cout << "Enter how many sides you want on the die: ";
cin >> max;
userRoll = rand() % (max - min + 1) + min;
return userRoll;
}
int userRolls() {
int userRoll;
int diceNum;
int min = 1;
int max;
cout << "Enter how many sides you want on the die: ";
cin >> max;
userRoll = rand() % (max - min + 1) + min;
cout << "Enter how many dice you want to roll: ";
cin >> diceNum;
return diceNum;
return userRoll;
}
int main() {
cout << oneDie() << endl;
cout << twoDie() << endl;
cout << userDie() << endl;
}