Question

I am currently attempting to create a simple blackjack game. In order to do so I...

I am currently attempting to create a simple blackjack game. In order to do so I have created an array for the values of my card like this, ValArray = ['A', '2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K']; what I need is to be able to assign a numerical value to each item in the array in order to count them. So that ‘A’ = 1 and ‘J’, ‘Q’, ‘K’ = 10. How do I assign these values to the array?

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

We can run a for loop in which we will traverse the array and assign numerical values to each character using conditional statements. We can write conditional statements like if-elseif-else to assign numerical values to the elements of the array.

if element of valArray is 'A'

assign it value 1;

else if element of valArray is '2'

assign it value 2;

else if element of valArray is '3'

assign it value 3;

else if element of valArray is '4'

assign it value 4;

else if element of valArray is '5'

assign it value 5;

else if element of valArray is '6'

assign it value 6;

else if element of valArray is '7'

assign it value 7;

else if element of valArray is '8'

assign it value 8;

else if element of valArray is '9'

assign it value 9;

else

assign it value 10;

the logic is same but the syntax can vary according to the programming language. For example, we can use directory or vector,etc. according to the programming language we choose.

In this way we can assign the numerical value to the elements of valArray

Add a comment
Know the answer?
Add Answer to:
I am currently attempting to create a simple blackjack game. In order to do so I...
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
  • NEED HELP TO CREATE A BLACKJACK GAME WITH THE UML DIAGRAM AND PROBLEM SOLVING TO GET...

    NEED HELP TO CREATE A BLACKJACK GAME WITH THE UML DIAGRAM AND PROBLEM SOLVING TO GET CODE TO RUN!! THANKS Extend the DeckofCards and the Card class in the book to implement a card game application such as BlackJack, Texas poker or others. Your game should support multiple players (up to 5 for BlackJack). You must build your game based on the Cards and DeckofCards class from the book. You need to implement the logic of the game. You can...

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

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

  • Next, we will be writing a program that interprets pairs of playing cards as a blackjack...

    Next, we will be writing a program that interprets pairs of playing cards as a blackjack hand and prints the overall value. Each card can be only one of the following chars, 'A', 'K', 'Q', 'J', 'T', '9', '8', '7', '6', '5', '4', '3', '2'. The values of an 'A' can be a 1 or 11, the value of 'T', 'J', 'Q', and 'K' are each 10, the value of all other cards is the number of the card To...

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

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

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

  • PIUBlem 2. The Video Game Question. When I am not grading the ridiculous amounts of game. Let's t...

    PIUBlem 2. The Video Game Question. When I am not grading the ridiculous amounts of game. Let's talk statistics of digital card games. exams I have this semester, I play a digital card a) According to a website that tracks statistics, the deck I currently am playing has a 63% win-rate. It 1 plan to play 10 games tonight before I start grading, what is the probability that I win 8 or more of them? b) Rather than play a...

  • Actually, I am trying to upload the picture, but it does not work as well. So,...

    Actually, I am trying to upload the picture, but it does not work as well. So, i just gotta tell you my question and this should be the output on the screen: Please enter in 5 string: a b c d e Please enter in another 5 strings: q w e r t STATS Total character count of array A: 5 Vowel character count of array A: 2 Total character count of array B: 5 Vowel character count of array...

  • Given these three classes: Card, DeckOfCards, and DeckOfCardsTest. Extend the DeckofCards class to implement a BlackJack...

    Given these three classes: Card, DeckOfCards, and DeckOfCardsTest. Extend the DeckofCards class to implement a BlackJack class, which implements a BlackJack game. Please do not use any java applet on the coding. Hint: Use a test class to test above classes. Pulic class Card {    private final String face; // face of card ("Ace", "Deuce", ...)    private final String suit; // suit of card ("Hearts", "Diamonds", ...)    // two-argument constructor initializes card's face and suit    public...

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