-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSlotMachine.cpp
55 lines (51 loc) · 1.28 KB
/
SlotMachine.cpp
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
#include <iostream>
#include <stdlib.h>
#include <time.h>
using namespace std;
int main()
{
int random = 0;
int output = 0;
int numone = 0;
int numtwo = 0;
int numtre = 0;
int points = 0;
int tokens = 100;
char yorn;
cout<<"Roll? (Y/N)";
srand((unsigned) time(NULL));
cin>>yorn;
while((yorn=='y')||(yorn=='Y')&&(tokens>0)){
tokens--;
random = 1+(rand()%3);
numone=random;
random = 1+(rand()%3);
numtwo=random;
random = 1+(rand()%3);
numtre=random;
cout<<"\n\n["<<numone<<"] ["<<numtwo<<"] [";
cout<<numtre<<"]";
points=numone+numtwo+numtre;
if ((numone==1)&&(numtwo==1)&&(numtre==1)){
tokens=tokens+3;
cout<<"\n\nYou Win 3 Tokens!\nYou Have:"<<tokens<<" Tokens.";
}
else if((numone==1)&&(numtwo==1)&&(numtre==1)){
tokens=tokens+6;
cout<<"\n\nYou Win 6 Tokens!\nYou Have:"<<tokens<<" Tokens.";
}
else if ((numone==3)&&(numtwo==3)&&(numtre==3)){
tokens=tokens+3;
cout<<"\n\nYou Win 9 Tokens!\nYou Have:"<<tokens<<" Tokens.";
}
else
cout<<"\n\nYou Lost!\nYou Have:"<<tokens<<" Tokens.";
if(tokens==0){
break;}
cout<<" Roll Again? (Y/N) ";
cin>>yorn;
}
if(tokens==0){
cout<<"\n\nYou Ran out of money! You're now broke! Press Any Key to exit\n";
system("pause");}
}