Dice game, How to go to next step.
.
Last edited on
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
void printDice();
int main()
{
srand(time(0));
int numOfDice;
numOfDice =6;
int erase;
char rollAgain = 'y';
int dice[6];
while(rollAgain == 'y')
{
for(int k=0; k<numOfDice; k++)
{
dice[k] = rand()%6+1;
}
for(int k=0; k<6; k++)
{
cout<<dice[k]<< " ";
}
cout<<endl;
int counter;
counter = 0;
for(int k=0; k<numOfDice; k++)
{
if(dice[k]==1)
{
counter++;
}
}
int counter2;
counter2=0;
for(int k=0; k<numOfDice; k++)
{
if(dice[k]==2)
{
counter2++;
}
}
int counter3;
counter3=0;
for(int k=0; k<numOfDice; k++)
{
if(dice[k]==3)
{
counter3++;
}
}
int counter4;
counter4=0;
for(int k=0; k<numOfDice; k++)
{
if(dice[k]==4)
{
counter4++;
}
}
int counter5;
counter5=0;
for(int k=0; k<numOfDice; k++)
{
if(dice[k]==5)
{
counter5++;
}
}
int counter6;
counter6=0;
for(int k=0; k<numOfDice; k++)
{
if(dice[k]==6)
{
counter6++;
}
}
cout<< "Here are the count of 1s: "<<counter<<endl;
cout<< "Here are the count of 2s: "<<counter2<<endl;
cout<< "Here are the count of 3s: "<<counter3<<endl;
cout<< "Here are the count of 4s: "<<counter4<<endl;
cout<< "Here are the count of 5s: "<<counter5<<endl;
cout<< "Here are the count of 6s: "<<counter6<<endl;
cout<< "How many do you want to remove: "<<endl;
cin>>erase;
numOfDice = numOfDice - erase;
for(int k=0; k<numOfDice; k++)
{
cout<<dice[k]<<" ";
}
cout<<endl;
cout<<" Do you want to roll again ? ";
cin>>rollAgain;
}
printDice();
int options;
int score=0;
cout<< " Choose your options"<<endl;
cin>>options;
switch(options)
{
case 1: if(dice[numOfDice]== 1)
{
score = score + 100;
cout<< "Your score is "<<score<<endl;
}
}
cout<<dice[numOfDice];
return 0;
}
void printDice()
{
cout<< " ** Dice Combination"<<" " << " Score **"<<endl;
cout<< " 1. Each 1"<<" "<<" 100 "<<endl;
cout<< " 2. Each 5"<<" "<< "50"<<endl;
cout<< " 3. Three 1s"<<" "<< "1000"<< endl;
cout<< " 4. Three 2s"<<" "<< "200"<< endl;
cout<< " 5. Three 3s"<<" "<< "300"<< endl;
cout<< " 6. Three 4s"<<" "<< "400"<< endl;
cout<< " 7. Three 5s"<<" "<< "500"<< endl;
cout<< " 8. Three 6s"<<" "<< "600"<< endl;
}
|
Hey TC, what did you do with your post? Leaving so soon after someone has given you an answer, perhaps...?
Topic archived. No new replies allowed.