Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*****************************************************************************************************
- * Program Name: Prog 06
- * Author: Patrick Barnett
- * Date: 12 / 11 / 19
- * Course/Section CSC - 110 - 302
- * Program Description:
- * Slot machine game. Asks user for how much money they would like to start with. Then will ask for
- * a wager amount. The slot machine will *spin* and give you a number (1-7). The goal is to get
- * at least two like numbers, triple sevens nets you triple your wager.
- *
- *****************************************************************************************************/
- /**************************************** Compiler Directives ***************************************/
- #include "pch.h"
- #include <string>
- #include <cstdlib>
- #include <iostream>
- #include <iomanip>
- #include <cmath>
- using namespace std;
- /************************************ Global Data Declarations **************************************/
- // None in this program.
- /************************************* Function Prototypes ******************************************/
- //None in this program.
- /*****************************************************************************************************
- Function Name: Main
- Author: Patrick Barnett
- Date: 12/11/2019
- Function Description:
- Asks user for how much money they will be betting with. Gets a wager amount, then spins. if
- numbers match double or triple the wager.
- Pseudocode:
- Level 0
- -------
- Seed generator
- Ask user for bank
- Ask for wager amount
- Spin The Slots
- Check spin for like numbers
- Bank ran out
- level 1
- -------
- Seed generator
- srand(static_cast<unsigned int>(time(0)))
- Ask user for bank
- output "How much money will you be playing with today?"
- input bank
- Ask for wager amount
- output "What is your wager on this spin?"
- if wager > bank then
- output "You don't have that much to wager."
- else
- input wager
- bank -= wager
- Spin The Slots
- for counter = 0 to SIZE-1 by +1
- spin[counter] = (rand() % (7 - 1 + 1)) + 1
- Check spin for like numbers
- else if spin[0] == spin[1] then
- bank += wager * 2
- else if spin[1] == spin[2] then
- bank += wager * 2
- else if spin[2] == spin[0] then
- bank += wager * 2
- check for lucky sevens
- for counter = 0 to SIZE-1 by +1
- luckyseven += spin[counter]
- if luckyseven == 21 then
- bank += wager * 3
- Bank ran out
- output "thanks for plying please come back again!"
- *******************************************************************************************************/
- /********************************** Main Function ***************************************************/
- int main()
- {
- //Local Constant
- const int SIZE = 3;
- //local Variables
- int spin[SIZE];
- int bank;
- int wager;
- int counter;
- int luckyseven = 0;
- int spincount = 1;
- /********************** Begin Main Function Executables ********************************/
- //Seed the generator
- srand(static_cast<unsigned int>(time(0)));
- //Ask for bank
- cout << "How much money would you like to gamble with today? ---> ";
- cin >> bank;
- //Ask for wager
- while (bank > 0)
- {
- cout << "What would you like to wager on this spin? ";
- cin >> wager;
- if (wager > bank)
- cout << "You do not have that much to bet!" << endl;
- else if ((isdigit(wager)) == false)
- cout << "You entered in a letter instead of a number.";
- else
- {
- bank -= wager;
- //Spin the slots
- cout << "Time to spin the slots!! Spin Count: " << spincount << endl;
- spincount++;
- cout << "+-+-+-+" << endl;
- for (counter = 0; (counter <= (SIZE - 1)); counter++)
- {
- spin[counter] = (rand() % (7 - 1 + 1)) + 1;
- cout << "|" << spin[counter];
- }
- cout << "|" << endl << "+-+-+-+" << endl;
- //Check for Lucky sevens
- for (counter = 0; (counter >= (SIZE - 1)); counter++)
- luckyseven += spin[counter];
- if (luckyseven == 21)
- {
- bank += wager * 3;
- cout << "CONGRATS YOU WON IT BIG!!!";
- }
- //Check for like numbers
- else if (spin[0] == spin[1])
- {
- bank += wager * 2;
- cout << "Congrats, You had two like numbers" << endl;
- }
- else if (spin[1] == spin[2])
- {
- bank += wager * 2;
- cout << "Congrats, You had two like numbers" << endl;
- }
- else if (spin[2] == spin[0])
- {
- bank += wager * 2;
- cout << "Congrats, You had two like numbers" << endl;
- }
- cout << "You currently have $" << bank << endl;
- }
- }
- //Bank Ran out
- cout << "Dang looks like your lucky streak is over matey. You had " << spincount << " successful winning spins!!" << endl;
- //Hold output
- system("pause");
- //Indicate to OS successful termination of program
- return 0;
- } //End Main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement