Code:
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <string>
#include <algorithm>
using namespace std;
int dieRoll();
int main(int argc, char* argv)
{
int looper = 0;
int arrRolls[6];
int roll;
string again = "";
srand((unsigned)time(0));
do{
for (int k = 0; k < 6; k++)
{
arrRolls[k] = 0;
}
for (int i = 1; i <= 100; i++)
{
roll = dieRoll();
cout << "Die Roll " << i << ": " << roll << endl;
arrRolls[roll - 1]++;
}
for (int j = 0; j < 6; j++)
{
cout << j + 1 << " : " << arrRolls[j] << " times." << endl;
}
start:
cout << "Would you like to roll the dice again(Yes or No)?:" << endl;
cin >> again;
transform(again.begin(), again.end(), again.begin(), tolower);
} while (again == "yes");
if (again != "no" && again != "yes"){
cout << "Please enter yes or no." << endl;
goto start;
}
return 0;
}
int dieRoll()
{
int result;
result = (rand() % 6) + 1;
return result;
}
Comment