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...

  • Must be in C++ Question: Blackjack (twenty-one) is a casino game played with cards. The goal...

    Must be in C++ Question: Blackjack (twenty-one) is a casino game played with cards. The goal of the game to draw cards that total as close to 21 points as possible without going over. All face cards count as 10 points, aces count as 1 or 11, and all other cards count their numeric value. The game is played against a dealer. The player tries to get closer to 21 (without going over) than the dealer. If the dealer busts...

  • 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....

  • "Blackjack 40" my teacher created this assignment and I need help. He is using c++ and...

    "Blackjack 40" my teacher created this assignment and I need help. He is using c++ and has provided this template: Further instructions are below the template! #include <iostream> #include <cmath> #include <cstdlib> using namespace std; //Will return a number from 1 to 13, representing the face of a card int draw_card() { return rand() % 13 + 1; } int main() { const int BET = 10; //This will allow you to control chance, to make testing easier cout <<...

  • 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...

  • For this assignment you will create a one-player variation of the game BlackJack. The game will...

    For this assignment you will create a one-player variation of the game BlackJack. The game will be divided into five rounds. The goal of each round is to accumulate a hand of cards that gets as close to 21 without going over. At the beginng of the game you will start with a score of 100 points. After each round, the difference between your hand and 21 will be subtracted from your total score. The object of the entire game...

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