3/22/2016

C++ Program For Casino Game : Number Guessing Program ( GAME PROJECT )

Project:- Number guessing game c++ source code or C++ Program For Casino Game or casino number-picking game or casino number-picking game in c++ or Developing guess game in C++ step by step or c++ - Text-based casino game or games in c++ without graphics or c++ slot machine code or Slot Machine Example in C++ or slot machine game c++ or code for slot machine game in c++ casino game code in c++ or .

Check This:- Hacker rank solution for Strings, Classes, STL, Inheritance in C++.

Explanation:- Casino Game or Number Guessing Game both are same, in Casino we have to guess a number and if the number is matched with the Winning Number or Random Number than you will win the Lots of Money. Here in the programming language we have a random number instead of Guess the number is real life. Let explanation our code step by step, First we will Take a Username and total amount of Money in Deposit, Now player can play a Casino Game or Number Guessing Game but before playing a game player need to Bid for every time, Let's Take an example and try to understand the Casino Game or Number Guessing Game.

Example:- Suppose I am a Player My Name is Ghanendra and I have total 5000$ Money. I deposited My total money and Strat playing a Casino Game or Number Guessing Game First I took a Bid 1000$ and I guess the Number 7(Between 1 to 10) if the random number generated by computer is 7 then I can win 10 times of My Bid amount and if I lose My remaining Money is 4000$. Now I can play More until I have a single penny or maybe I can Win or Maybe not.
  
Also Check:- Geeksforgeeks solution for School, Basic, Easy, Medium, Hard in C++.

Extreme Recommended:- Like our Facebook Page or Join our Facebook Group and Google plus Community for up-to-date for a new post or if you have any Query you can ask there with lots of coders also suggest to your Friends to join and like our page, so we can help our community, and don't forget to Subscribe. Enter your Email and click to subscribe.

Tip:- If you have any query feel free to share with me, and if you like my work please share, comments and subscribe for our new and latest post related to programming this will help you update all about new post this Article.

Solution:-

#include <iostream>
#include <string>
#include <cstdlib>
#include <ctime>
using namespace std;

void rules();

int main()
{
    string name;
    int amnt; 
    int bidamnt;
    int guess;
    int dice; 
    char choice;

    srand(time(0)); // Use for Generating Random Number Each Time.

cout<<"\n===============================================================================================";
cout<<"\n   CCCCC      A        SSSSSSSSS   IIIIIIIII  NN     NN    OOOOOOOO     ";
cout<<"\n CC          A  A      SS             III     NN N   NN   OO      OO    ";
cout<<"\nCC          A    A     SSSSSSSSS      III     NN  N  NN   OO      OO    ";
cout<<"\n CC        AAAAAAAA           SS      III     NN   N NN   OO      OO    ";
cout<<"\n   CCCCC  A        A   SSSSSSSSS   IIIIIIIII  NN     NN    OOOOOOOO     ";
cout<<"\n===============================================================================================\n";
    cout <<"\nEnter Player Name: ";
    getline(cin, name);

    cout <<"\nDeposit Your Amount: $";
    cin >> amnt;
   
    do
    {
        system("cls");
        rules();
        do
        {
            cout <<"\nWelcome "<<name<<" Are You Ready To Play? "<<"\n\n"; 
cout<<"Enter Bid Amount: $";
            cin >> bidamnt;
            if(bidamnt > amnt)
                cout <<"You Can not Bid More Than Current Amount\n"
                       <<"\nRe-enter Amount: ";
        }while(bidamnt > amnt);

        do
        {
            cout <<"Guess The Number Between 1 To 10 :";
            cin >> guess;
            if(guess <= 0 || guess > 10)
                cout << "\nNumber Sholud Be Between 1 To 10\n"
                    <<"\nGuess Numer Again: ";
        }while(guess <= 0 || guess > 10);

        dice = rand()%10 + 1;
   
        if(dice == guess)
        {
            cout <<"\nHurray You Won " << bidamnt * 10<<"$";
            amnt = amnt + bidamnt * 10;
        }
        else
        {
            cout << "Sorry You Lose "<< bidamnt <<"$\n";
            amnt = amnt - bidamnt;
        }

        cout << "\nThe Winning Number Was: " << dice <<"\n";
        cout << "\n"<<name<<", Your Remaining Amount Is " << amnt << "$\n";
        if(amnt == 0)
        {
            cout << "\nSorry You Don't Have Money To Play \n";
            break;
        }
        cout << "\nYou Want To Play Again Press (y/n)? "; 
        cin >> choice;
    }while(choice =='Y'|| choice=='y');
   
    cout<<"\n===============================================================================================\n";
    cout << "Thanks For Playing Game Again Your Current Amount Is " << amnt << "$";
    cout<<"\n===============================================================================================\n";

    return 0;
}

void rules()
{
    system("cls");
    cout<<"\n===============================================================================================\n";
    cout << "\t\t\tGame Rules";
    cout<<"\n===============================================================================================";
    cout << "\n1. Choose Number Between 1 To 10";
    cout << "\n2. Winning Amount Will Be 10 Times Of Bid Amount";
    cout << "\n3. Loose Amount Will Be Biding Amount";
    cout << "\n4. You Can Leave A Game Any Time";
    cout<<"\n===============================================================================================\n";
}

Output:-

Welcome Screen

casino game code in c++

Game Rules

casino game code in c++

Guessing Number

casino game code in c++

Running Without Balance

casino game code in c++


Check Other Projects


C++ Project's


1.C++ Program For Student Report Card ( SRC PROJECT ) With Source Code

2.C++ Program For School Management System ( SMS Project ) With Source Code

3.C++ Program For HANGMAN ( GAME PROJECT ) With Source Code

4. C++ Tic Tac Toe Game Project With Source Code

Java Project's

1.JAVA Project SMS (School Management System) Using Multiple Classes

2.Java Program For Calculator Using AWT Controls (GUI)

20 comments:

  1. Replies
    1. Thanks for visiting and Thanks for your comment

      Delete
  2. I love this blog!! The flash up the top is awesome!! 토토픽

    ReplyDelete
    Replies
    1. Thanks for comment but I don't know Korean.

      Delete
  3. I sent your articles links to all my contacts and they all adore it including me.https://online-casino-osterreich.at

    ReplyDelete
    Replies
    1. Glad to hear that you like this article please keep sharing with your friends.

      Delete
  4. I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well. Thanks... situs betting indonesia

    ReplyDelete
    Replies
    1. Thanks You For Liking My Article on Casino Program game in C++.

      Delete
  5. Thank you for very usefull information.. judi bola deposit 10rb

    ReplyDelete
    Replies
    1. Welcome You Keep share with your friends.

      Delete
  6. If you somehow managed to locate an online casino where no one really plays at, well, at that point chances are that you will locate a hard time in enrolling new players to that specific casino at any rate. play blackjack in new jersey

    ReplyDelete
    Replies
    1. Nice thought but I don't think that I am going to support Gaming. I am a coder and I support in solving programming problem and issues.

      Delete
  7. The security technologies that online casinos employ are designed to protect the player because he is the most valuable asset of online casinos.gambling backlinks

    ReplyDelete
    Replies
    1. Please Don't Support Gambling. Thanks for visiting

      Delete
  8. Whatever you have provided for us in these posts really appreciative.questions

    ReplyDelete
    Replies
    1. Thanks for your comment, I think You like my post most please share and show your support.

      Delete
  9. This is a great inspiring article.I am pretty much pleased with your good work.You put really very helpful information. Keep it up. Keep blogging. Looking to reading your next post. Agen domino

    ReplyDelete
    Replies
    1. Greeting for your support and thanks for you like this article.

      Delete
  10. Great post, and great website. Thanks for the information! 온라인바카라

    ReplyDelete
  11. This comment has been removed by the author.

    ReplyDelete