Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.95 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <cstdlib>
  4. using namespace std;
  5.  
  6. int GetBet();
  7. string PullOne();
  8. int GetPayMultiplier(string s1, string s2, string s3);
  9. void Display(string s1, string s2, string s3, int winnings);
  10.  
  11.  
  12. int main()
  13. {
  14.    int theBet = GetBet();
  15.    srand (time (NULL));
  16.    while (theBet != 0)
  17.    {
  18.    PullOne();
  19.    string first = PullOne();
  20.    PullOne();
  21.    string second = PullOne();
  22.    PullOne();
  23.    string third = PullOne();
  24.    int winnings = GetBet()*GetPayMultiplier(first, second, third);
  25.    Display(first, second, third, winnings);
  26.    }
  27. }
  28.  
  29. int GetBet()
  30. {
  31.    int theBet;
  32.    cout << "Please place a bet from $1 to $100. Do not include $ in your input."
  33.            " 0 to quit.\n";
  34.    cin >> theBet;
  35.    while (theBet > 100 || theBet < 0)
  36.    {
  37.       cout << "Please input a valid number\n";
  38.       cin >> theBet;
  39.    }
  40.    if (theBet == 0)
  41.    {
  42.       cout << "Goodbye.";
  43.       exit(0);
  44.    }
  45.    return (theBet);
  46. }
  47.  
  48. string PullOne()
  49. {
  50.    int slotChoices = 4;
  51.    string slotPull[slotChoices];
  52.       slotPull[0] = "cherries";
  53.       slotPull[1] = "BAR";
  54.       slotPull[2] = "space";
  55.       slotPull[3] = "7";
  56.    return slotPull[rand() % 4];
  57. }
  58.  
  59. int GetPayMultiplier(string s1, string s2, string s3)
  60. {
  61.    int multiplier;
  62.    if (s1 == "cherries" && s2 != "cherries")
  63.       multiplier = 3;
  64.    else if (s1 == "cherries" && s2 == "cherries" && s3 != "cherries")
  65.       multiplier = 10;
  66.    else if (s1 == "cherries" && s2 == "cherries" && s3 == "cherries")
  67.       multiplier = 20;
  68.    else if (s1 == "BAR" && s2 == "BAR" && s3 == "BAR")
  69.       multiplier = 35;
  70.    else if (s1 == "7" && s2 == "7" && s3 == "7")
  71.       multiplier = 50;
  72.    return (multiplier);
  73. }
  74.  
  75. void Display(string s1, string s2, string s3, int winnings)
  76. {
  77.    cout << s1 << " " << s2 << " " << s3 << "\n";
  78.    if (winnings == 0)
  79.       cout << "Sorry, you didn't win anything. Please try again.\n";
  80.    else cout << "You won $" << winnings << "!\n";
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement