This is my code for my program, it seems to work fine but the problem is i think roll has to be a char in order for q to quit to work when i implement the code in there. but when i use char, when i input the number i want it to randomize, its obviously not the numbers i entered in the selection. how can i get a simple q to quit to work, please help.
#include <iostream>
#include <cmath>
#include <string>
#include <iomanip>
#include <cstdlib>
using namespace std;
int main()
{
int roll;
int side1 = 0;
int side2 = 0;
int side3 = 0;
int side4 = 0;
int side5 = 0;
int side6 = 0;
const int low = 1;
srand((unsigned)time(NULL));
cout << "\nHow many times would you like to roll the dice? (Enter 'Q' to Quit): ";
cin >> roll;
// Ensures 1 is not entered at all times
{
while (roll <= low)
{
cout << "\nPlease enter a number greater than 1: ";
cin >> roll;
}
// Random Number Code in the range of what the user inputed for roll
}
for ( int i = 0; i < roll; i++ )
{
int counter = rand() % 6 + 1;
// Switch statement to switch each (dice side) with rand function
switch ( counter )
{
case 1:
side1++;
break;
case 2:
side2++;
break;
case 3:
side3++;
break;
case 4:
side4++;
break;
case 5:
side5++;
break;
case 6:
side6++;
break;
}
}
const double percent = .100;
cout << "\n\nDice Roll Statistics";
cout << setw(2) << " \n\n# Rolled" << setw(10) << " # Times" << setw(11) << " % Times\n";
cout << setw(2) << " -------" << setw(10) << " -------" << setw(12) << " -------\n\n";
cout << setw(9) << "1 " << setw(9) << side1 << setw(7) << "% " << side1/percent << endl;
cout << setw(9) << "2 " << setw(9) << side2 << setw(7) << "% " << side2/percent << endl;
cout << setw(9) << "3 " << setw(9) << side3 << setw(7) << "% " << side3/percent << endl;
cout << setw(9) << "4 " << setw(9) << side4 << setw(7) << "% " << side4/percent << endl;
cout << setw(9) << "5 " << setw(9) << side5 << setw(7) << "% " << side5/percent << endl;
cout << setw(9) << "6 " << setw(9) << side6 << setw(7) << "% " << side6/percent << endl << endl;
system("PAUSE");
return 0;
}