#include #include #include // Simple Slot Machine Program // Without Graphical Interface, basically just numbers... // Global variables int choice, a, b, c, tokens = 4; // The function prototypes void randomizeNums(); void checkForWin(int a, int b, int c); void main() { srand(time(0)); // Initialize Seed choice = 0; while (choice != 2 && tokens > 0) { cout << "***************" << endl; cout << "* SLOTS *" << endl; cout << "* 1. Spin! *" << endl; cout << "* 2. Exit *" << endl; cout << "* Tokens: " << tokens << " *" << endl; cout << "***************" << endl; cin >> choice; tokens--; randomizeNums(); cout << "Your spin: " << endl; cout << "* " << a << " * " << b << " * " << c << " *" << endl; checkForWin(a, b, c); cout << endl << endl; choice = 0; system("pause"); system("cls"); } if (tokens == 0) cout << "You have run out of tokens." << endl; cout << "Thank you for playing..." << endl; } void randomizeNums() { a = 1 + rand() % 5; b = 1 + rand() % 5; c = 1 + rand() % 5; } void checkForWin(int a, int b, int c) { if (a == b == c) { cout << "Three of a kind! Jackpot! 4 Tokens!" << endl; tokens = tokens + 4; cout << "Token Count: " << tokens << endl; } else if (a == b || a == c || b == c) { cout << "Two of a kind! 2 Tokens!" << endl; tokens = tokens + 2; cout << "Token Count: " << tokens << endl; } else { cout << "Nothing..."; } }