Question

This is a must for a C++ project.

Blackjack Requested files: Blackjack.cpp (Download) Type of work: Individual work You MUST have grade 70 or higher on the quiSample Output: > First cards: 3, 2 > Total: 5 > Do you want another card? (y/n): y >Card: 6 > Total: 11 > Do you want anotherClarifying Questions to Ask Yourself When you are designing and implementing Blackjack you should consider: 1. Are your rando

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

// Feel free to post a comment if you have any queries

// And upvote the answer if you like it

// Output at the bottom

#include <iostream>
#include <time.h>

using namespace std;

int getRandomNumber() {
return rand() % 10 + 1;
}

int main() {
const int dealerHand = 18;
srand(time(0));
int r;
char replay = 'y';
char anotherCard;
int sum;

while(replay == 'y') {
sum = 0;
cout << "First cards: ";
r = getRandomNumber(); // Get a random number
sum = r; // Set sum equal to the first number
r = getRandomNumber(); // Get another random number
cout << r << ", " << sum << endl; // Note: sum = first number, r = second number (in here)
sum += r;
cout << "Total: " << sum << endl; // Total is calculated and displayed

cout << "Do you want another card? (y/n): ";
cin >> anotherCard;
while(anotherCard == 'y') {
r = getRandomNumber();
cout << "Card: " << r << endl;
sum += r;
cout << "Total: " << sum << endl;

if(sum >= 21) {
break;
}

cout << "Do you want another card? (y/n): ";
cin >> anotherCard;
}

// Conditions
if(sum == 21) {
cout << "Blackjack" << endl;
} else if(sum > 21) {
cout << "Bust" << endl;
} else if(sum > dealerHand) {
cout << "Win" << endl;
} else if(sum == dealerHand) {
cout << "Push" << endl;
} else cout << "Lose" << endl;

cout << endl;
cout << "Would you like to play again? (y/n): ";
cin >> replay;
}
}

t/Programs/HomeworkLib First cards: 6, 4 Total: 10 ./Blackjack Do you want another card? (y/n): y Card: 1 Total: 11 Do you want ano

Would you like to play again? (y/n): y First cards: 7, 6 Total: 13 Do you want another card? (y/n): y Card: 10 Total: 23 Bust

Add a comment
Know the answer?
Add Answer to:
This is a must for a C++ project. Blackjack Requested files: Blackjack.cpp (Download) Type of work:...
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
  • 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...

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

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

  • Note: Please write the Pseudocode using Arrays method in Java language. Program 2 (40%); For this...

    Note: Please write the Pseudocode using Arrays method in Java language. Program 2 (40%); For this assignment, we're going to make a game. Imagine you initially start with a random "hand" of two cards (values 2-9). Your goal is to continue to add to your hand until the sum of the cards is between 21 25, at which point youu win. Further, if you hold 5 cards, you win. However, if you exceed a sum of 25, you lose. Admittedly,...

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

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

  • Game of Craps C++ #include <iostream> using namespace std; void roll (int *); // using pointer...

    Game of Craps C++ #include <iostream> using namespace std; void roll (int *); // using pointer to catch the random variable value of two dicerolls at one time . //these global variable with static variable win use to operate the working of code . //static win, account because two times input given by user to add the diceroll with win number and //account (means balance of user) . static int account = 100; static int win = 0; int bet...

  • Write a Java program to simulate Blackjack. The program should be as basic as possible while...

    Write a Java program to simulate Blackjack. The program should be as basic as possible while following the rules below. Thanks a. There is one deck of cards b. Cards are drawn randomly using (Shuffle() method) c. The value of a hand is computed by adding the values of the cards in hand d. The value of a numeric card such as four is its numerical value e. The value of a face card is 10 f. Ace is either...

  • "Red Dog" in C++ Problem 1 Red Dog (Points: 100/100) We will be writing a program...

    "Red Dog" in C++ Problem 1 Red Dog (Points: 100/100) We will be writing a program that lets you play the game "Red Dog". A description of the game can be found here: https://en.wikipedia.org/wiki/Red dog_(card game). This is also sometimes termed an "in-between" Acey Deucey. Red Dog is a game that is played with a standard 52-card deck. Suits are not considered in the game, all that matters is the order of cards, which from high to low runs Ace...

  • Specifications: C++ each class should have a header file all files must create a console application...

    Specifications: C++ each class should have a header file all files must create a console application in Visual Studio We want to design our die class (to be named aDie) such that we can have statements such as: aDie D; // To instantiate a Die object int rolled = D; // To get the value rolled by D rolled = D + D; // To get the value of the sum of 2 rolls of the die aDie d1, d2;...

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