Question

programming language c++

1:26 #WW 2.53% Example: A user starts with 1000 points. Game #1 - user chooses to risk 200 points. User wins game (beats the

1:26 ww . al 52% dileveu. The players total is compared to the dealers total and the highest one <= 21 wins. If the player

1:26 #WWE.. # 52% lace caru ack, queen or kilig) are each worth 10 The ace is worth either 1 or 11. If the sum of cards (deal

its a project if anyone can help me it's will be appreciated thnk u.
u have to create a code based on the information im giving u

you can do it in 1 or 2 day i can wait

0 0
Add a comment Improve this question Transcribed image text
Answer #1

// header files
#include<iostream>    //input/output
#include<stdlib.h>   //function to generate random values
#include<time.h>   //to obtain time
using namespace std;
int cardValue(int card){
   if(card>10){
        return 10;  
   }
   else if(card==1){
       return 11;
   }
   else{
       return card;
   }
  
}

int main(){
   int points=1000,dcard,cardDrawn,round=1,dealer,player,pointToRisk,pAce,dAce;
   int pcard[5];
   char ch;
    // Initialize random value for shuffling the deck
    srand(time(0));
   do{
       cout<<"\nGame : "<<round<<endl;
        // Random values for swapping of positions.
       dealer=0;
       player=0;
       cardDrawn=0;
       pAce=0;
       dAce=0;
       cout<<"Total poinst available: "<<points<<"\nEnter the points to risk: ";
       cin>>pointToRisk;
       //dealing first card
        dcard = 1 + (rand() % (13));
        if(dcard==1){
           dAce++;
       }
        //adding the card value to the dealers value
       dealer=dealer+cardValue(dcard);
       //dealing first card      
        dcard = 1 + (rand() % (13));
        if(dcard==1){
           dAce++;
       }
        //adding the card value to the dealers value
       dealer=dealer+cardValue(dcard);

       //dealing first card
        pcard[cardDrawn] = 1 + (rand() % (13));
        if(pcard[cardDrawn]==1){
           pAce++;
       }
        //adding the card value to the dealers value
       player=player+cardValue(pcard[cardDrawn]);
       cardDrawn++;
       //dealing second card      
        pcard[cardDrawn] = 1 + (rand() % (13));
        if(pcard[cardDrawn]==1){
           pAce++;
       }
        //adding the card value to the dealers value
       player=player+cardValue(pcard[cardDrawn]);

       cardDrawn++;
       cout<<"\nPlayer score: "<<player<<endl;
       cout<<"\nAnother card?(y/n): ";
       cin>>ch;
       while(ch=='y' && cardDrawn<5){
          
           //dealing next card      
            pcard[cardDrawn] = 1 + (rand() % (13));
            //adding the card value to the dealers value
           player=player+pcard[cardDrawn];
           cardDrawn++;
           cout<<"\nPlayer score: "<<player<<endl;
           cout<<"\nAnother card?(y/n): ";
           cin>>ch;
          
       }
       if(cardDrawn>=5){
           cout<<"\n5 cards already drawn. ";
       }
       if(player>21 ){
           player=player-10*pAce;
       }
       if(dealer>21 ){
           dealer=dealer-10*dAce;
       }
       cout<<"\nDealer point= "<<dealer;
       cout<<"\nPlayer point= "<<player;
       if(player<=21 && player>dealer){
           cout<<"\nPlayer wins";
           points=points+pointToRisk;
       }
       else{
           cout<<"\nDealer wins";
           points=points-pointToRisk;
       }
      
       cout<<"\nPlayer's total point: "<<points;


       cout<<"\nDo you want to play another game?(y/n): ";
       cin>>ch;
       round++;
   }while(ch=='y');
  
}

Output:

Add a comment
Know the answer?
Add Answer to:
programming language c++ its a project if anyone can help me it's will be appreciated thnk...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • programming language c++ programming language c++ 1:25 #WW # 53% You may, if you wish, work...

    programming language c++ programming language c++ 1:25 #WW # 53% You may, if you wish, work in pairs; this means that a submission may have 2 names attached but those 2 people must have worked on the project. No free rides! The way to submit the program to me is as follows: put the entire program (main and any other functions) into a single compile. Compile it to be sure that you have the correct set of #include statements and...

  • Create a simplified Blackjack game using the Deck and Card classes (download the attached files to...

    Create a simplified Blackjack game using the Deck and Card classes (download the attached files to start).  There is also a "TestCard" class that creates a Deck and runs some simple code. You may choose to use this file to help you get started with your game program. 1) Deal 2 cards to the "player" and 2 cards to the "dealer".  Print both the player's cards, print one of the dealer's cards. Print the total value of the player's hand. 2) Ask...

  • Using C++ Create a Blackjack program with the following features: Single player game against the dealer....

    Using C++ Create a Blackjack program with the following features: Single player game against the dealer. Numbered cards count as the number they represent (example: 2 of any suit counts as 2) except the Aces which can count as either 1 or 11, at the discretion of the player holding the card. Face cards count as 10. Player starts with $500. Player places bet before being dealt a card in a new game. New game: Deal 2 cards to each...

  • Please write the program in python: 3. Design and implement a simulation of the game of...

    Please write the program in python: 3. Design and implement a simulation of the game of volleyball. Normal volleyball is played like racquetball, in that a team can only score points when it is serving. Games are played to 15, but must be won by at least two points. 7. Craps is a dice game played at many casinos. A player rolls a pair of normal six-sided dice. If the initial roll is 2, 3, or 12, the player loses....

  • Need a blackjack code for my assignment its due in 3 hours: it has to include...

    Need a blackjack code for my assignment its due in 3 hours: it has to include classes and object C++. Create a fully functioning Blackjack game in three separate phases. A text based version with no graphics, a text based object oriented version and lastly an object oriented 2D graphical version. Credits (money) is kept track of throughout the game by placing a number next to the player name. Everything shown to the user will be in plain text. No...

  • You are helping a corporation create a new system for keeping track of casinos and customers....

    You are helping a corporation create a new system for keeping track of casinos and customers. The system will be able to record and modify customer and casino information. It will also be able to simulate games in the casino. You may complete this project individually or in a group of no more than 2 other people. Requirements do not change if you choose to complete the project individually or as part of a group. Customer-specific requirements You can create...

  • I need to build the card game of War in C++. It will be a 2...

    I need to build the card game of War in C++. It will be a 2 player game. Each player will have their own deck of 52 cards. 2-10, Jack=11, Queen=12, King=13, Ace=14. Each player will draw one card from their deck. The player with the higher card wins both cards. If the card drawn is the same, then each player will draw 3 cards and on the 4th card drawn will show it. The player that shows the higher...

  • How do I start this c++ code homework? Write a code in C++ for a BlackJack...

    How do I start this c++ code homework? Write a code in C++ for a BlackJack card game using the following simplified rules: Each card has a numerical value. Numbered cards are counted at their face value (two counts as 2 points, three, 3 points, and so on) An Ace count as either 1 point or 11 points (whichever suits the player best) Jack, queen and king count 10 points each The player will compete against the computer which represents...

  • C++ programming: Card game Can same one help me out with a example finsih and working...

    C++ programming: Card game Can same one help me out with a example finsih and working programm ? Program the basis for a card game (as a class card game): ● A card is represented by its suit/symbol (clubs, spades, hearts, diamonds) and a value (seven, eight, nine, ten, jack, queen, king, ace). ● A deck of cards consists of a pile of 32 cards that are completely connected to four players are distributed. ● Implement the following menu: ===...

  • You will write a two-class Java program that implements the Game of 21. This is a...

    You will write a two-class Java program that implements the Game of 21. This is a fairly simple game where a player plays against a “dealer”. The player will receive two and optionally three numbers. Each number is randomly generated in the range 1 to 11 inclusive (in notation: [1,11]). The player’s score is the sum of these numbers. The dealer will receive two random numbers, also in [1,11]. The player wins if its score is greater than the dealer’s...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT