C++ Problem

Write a C++ program of playing cards game. The game consists of the following
(20 marks)
● The game has two players, with each player taking one turn each.
● Each player receives from two to five cards from the deck. (The 1st player decides how
many will be distributed to each)
● There are a total of maximum 52 cards in the deck. A "standard" deck of playing cards
consists of 52 Cards in each of the 4 suits of Spades, Hearts, Diamonds, and Clubs.
Each suit contains 13 cards: Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King. .
● The cards 2 through 10 are scored as 2 through 10 points each. The face cards —Jack,
Queen and King — are scored as 10 points.
● The goal is to come as close to a score of 21 as possible without going over 21.
● Hence, any score over 21 is called “busted”.
● The ace card can count as either a 1 or 11, whichever is better for the user. For
example, an ace and a 10 can be scored as either 11 or 21. Since 21 is a better score,
this hand is scored as 21. An ace and two 8’s can be scored as either 17 or 27. Since 27
is a “busted” score, this hand is scored as 17.
The gameplay is given below:
● The 1st player is asked how many cards each player will receive, and the user responds
with one of the integers 2, 3, 4, or 5. Only one card value is chosen by each player - the
user choose any card except ace, while the rest of the cards are generated through
random values (ace can occur in random values). A good way to handle input is to use
the type char so that the card input 2, for example, is read as the character ’2’, rather
than as the number 2. Input the values 2 through 9 as the characters ’2’ through ’9’.
Input the values 10, jack, queen and king as the characters ’t’, ’j’, ’q’, ’k’, and ’a’. Be sure
to allow upper- as well as lowercase letters as input. After reading in the values, the
program should convert them from character values to numeric card scores. The output
for a particular player is either a number between 2 and 21 (inclusive) or the word
Busted. After turns of both players, the program shows the winner of the game (in case
one/both players scores under 21)

  Do Anyone know this?
this is a pointer to its own instance. But that is not your question?
Please provide the email address of your tutor, so that we can cut out the useless middleman.
At least he properly used code tags (you know, syntactically).

I will say though, sometimes it can look like someone is just looking for a handout, but if you ask for code they will actually respond with something. I guess it just isn't obvious to beginners that yes, what you've written so far, even if the compiler says it has some cryptic error, is still good to post.

Other times, they are just looking for a handout. So just in case it isn't clear: Talal, post the solution you've tried so far, and tell us a specific part you don't understand. If you don't understand anything, start with the tutorial on this site or a good book.

I don't know why I put even this amount of effort into this post.
Last edited on
Because you are the good guy ;)

#include <iostream>
#include <cctype>
#include <limits>

int main()
   std::cout << "Do you want someone to do all the work for you? ";
   char answer { };
   std::cin >> answer;

   std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');

   if (std::toupper(answer) == 'Y' ) { std::cout << "Post it in the Jobs section.\n"; }

   else { std::cout << "Show what you have coded so far.\n"; }

   std::cout << "Good luck.\n";
Registered users can post here. Sign in or register to post.