I am learning programming language first time, need help with compile the program.
Using the random number generation, I need to get the out put like this:
How many times you want to throw the dice (0 or less will stop the program)? 40
Face Frequency Percentage
-----------------------------------
1 8 20.0%
2 5 12.5%
3 6 15.0%
4 8 20.0%
5 5 12.5%
6 8 20.0%
-----------------------------------
Total 40 100.0%
Face 1: ********(8)
Face 2: *****(5)
Face 3: ******(6)
Face 4: ********(8)
Face 5: *****(5)
Face 6: ********(8)
How many times you want to throw the dice (0 or less will stop the program)?
I am using while loop and switch case, please guide me.
{
int num=0;
int i;
int face;
int frequency1 = 0;
int frequency2 = 0;
int frequency3 = 0;
int frequency4 = 0;
int frequency5 = 0;
int frequency6 = 0;
cout<< "How many times you want to throw the dice ( 0 or less will stop the program)? ";
cin>> num;
cout<<endl;
for(i = 1; 1<=40; i++)
{
face = 1+rand()%6;
switch (face)
{
case 1: ++frequency1;
break;
case 2: ++frequency2;
break;
case 3: ++frequency3;
break;
case 4: ++frequency4;
break;
case 5: ++frequency5;
break;
case 6: ++frequency6;
break;
}
}
return 0;
}