Advertisement
makispaiktis

Fruits Casino Game

Aug 27th, 2019 (edited)
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.98 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include <ctime>
  4. #include<math.h>
  5.  
  6. #define N 3
  7.  
  8. using namespace std;
  9.  
  10. int main()
  11. {
  12.     srand(time(NULL));
  13.  
  14.     // 1. Intro
  15.     cout << "Welcome to the famous casino game:  F R U I T S\n";
  16.     cout << "How much money do you have?\n\n";
  17.     float money;
  18.     cout << "Money: ";
  19.     cin >> money;
  20.     while(money <= 0){
  21.        cout << "Money: ";
  22.     cin >> money;
  23.     }
  24.     cout << endl;
  25.  
  26.     int counterOfRounds = 0;
  27.     int roundsWon = 0;
  28.  
  29.  menu:
  30.         counterOfRounds++;
  31.         // 2. Inserting bet
  32.         cout << endl << endl;
  33.         float bet;
  34.         cout << "* * * *  R O U N D  " << counterOfRounds << " * * * *" << endl << endl;
  35.         cout << "Insert your bet: ";
  36.         cin >> bet;
  37.         cout << endl;
  38.         while(bet <= 0){
  39.             cout << "Insert your bet: ";
  40.             cin >> bet;
  41.             cout << endl;
  42.         }
  43.         cout << endl;
  44.  
  45.         // 3. Beginning the game
  46.         int random1, random2, random3;
  47.         random1 = rand() % N + 1;
  48.         random2 = rand() % N + 1;
  49.         random3 = rand() % N + 1;
  50.  
  51.  
  52.         cout << random1 << "    " << random2 << "    " << random3 << endl << endl;
  53.  
  54.         // 4. Win or loss?
  55.         if(random1 == random2 && random1 == random3){
  56.             cout << "YOU WIN. You bet " << bet << " money and won " << bet * (N * N - 1) << endl;
  57.             roundsWon++;
  58.         }
  59.         else{
  60.             cout << "You lost " << bet << " money...";
  61.         }
  62.  
  63.         // Ask the user if he wants to continue
  64.         cout << "Continue? " << endl;
  65.         string reply;
  66.         cin >> reply;
  67.         if(reply == "no" || reply == "No" || reply == "No"){
  68.             goto exit;
  69.         }
  70.         else{
  71.             if(reply != "yes" && reply != "Yes" && reply != "Yes"){
  72.                 cout << "You replied '" << reply << "' instead of 'yes' or 'no', but I suppose you continue.\n";
  73.             }
  74.             goto menu;
  75.         }
  76.  
  77.  
  78. exit:
  79.  
  80.     return 0;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement