So I cant get the division to work on my c++ homework.
This is a diceroll game and im trying to get sum1=num1/diceRoll to get the percentage of # of times divided by the amount of time the dice is being rolled. It keeps giving me 0 because I assigned num1 to equal 0 which makes sense but it won't let me do without the 0. Any suggestions?? Thanks!
}
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <ctime>
using namespace std;
int main ()
{
const int maxDice =6;
int diceRoll;
int rolled;
int dice = 1;
int num;
int num1=0;
int num2=0;
int num3=0;
int num4=0;
int num5=0;
int num6=0;
double sum1;
srand ((unsigned int)time(NULL));
cout << "How many times would you like to roll the dice? ";
cin >> diceRoll;
for (rolled = 1; rolled <=diceRoll; rolled++)
{
num = rand() %6 +1;
if (num == 1)
{
num1++;
}
else if (num == 2)
{
num2++;
}
else if (num==3)
{
num3++;
}
else if (num==4)
{
num4++;
}
else if (num==5)
{
num5++;
}
else if (num==6)
{
num6++;
}
}
cout << "# Rolled # Times % Times" << endl;
sum1= num1/diceRoll;
cout << "1\t\t"<< num1 << " " << sum1 << endl ;
cout << "2\t\t" << num2 << endl << "2\t\t"<< num3 << endl;
cout << "4\t\t" <<num4 << endl <<"5\t\t" << num5 << endl << "6\t\t" << num6 << endl;
system ("PAUSE");
return 0;
}