Advertisement
Guest User

Untitled

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