Question: Write a C++ program that evaluates a poker hand. It does not play poker just reads poker hands and evaluates them. Each card in the
Write a C++ program that evaluates a poker hand. It does not play poker just reads poker hands and evaluates them. Each card in the hand will have both a suit (clubs, diamonds, hearts, or spades) and a rank (2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen, King, and Ace). The program will read a hand of five cards, and then classify the hand into one of the standard poker hand rankings listed below (best to worse):
If a hand falls into two or more categories, the program will choose the best one. Input will be from the keyboard and abbreviate the ranks and suits as follows:
Ranks: 2 3 4 5 6 7 8 9 T J Q K A
Suits: C D H S If the user enters an illegal card or tries to enter the same card twice, the program will ignore the card, issue an error message, and then request another card. Output the fully described hand. Finally, ask the user if he/she would like to play again (upper and lowercase). Use one dimensional arrays to represent data and do use any sorts. Do not use break or continue statements Use code provided by your instructor as a starting point. Refer to the sample output below.
Enter a card: AS Enter a card: 2C Enter a card: 4H Enter a card: 3D Enter a card: 5D
Hand: AS 2C 4H 3D 5D: Straight
Play again (Y/N)? Y
Enter a card: 8C Enter a card: AS Enter a card: 8C Duplicate Card. Try again. Enter a card: 7C
Enter a card: AD Enter a card: 3H
Hand: 8C AS 7C AD 3H: Pair
Enter a card: 6S Enter a card: 9C Enter a card: D2 Bad Card. Try again. Enter a card: 2D Enter a card: 4H Enter a card: TS
Hand: 6S 9C 2D 4H TS: High Card Play again (Y/N)? n
Play again (Y/N)? Y
Power Poker Hand Description Examples Value 10 | ROYAL FLUSH | The 10, Jack, Queen, King and Ace of the same | A.KeQ4JeT+ suit. This hand is the strongest of all poker hands. STRAIGHT FLUSH Five cards in sequence. Aces can play low or high. All cards belong to the same suit. Note that Ace may not "wrap around" and play both high and low or FOUROF A KIND Contains all four cards of one rank and any other 9e 9e 9 9v Jv (unmatched) card FULL HouS Contains three matching cards of one rank and 7e 7 7 4 44 two matching cards of another rank FLUSH All five cards are of the same suit, but not in sequence Five cards in sequence using at least two different | suits. Aces can play low or high. Note that Ace may not "wrap around" and play both high and low 9+ 7443 A+ K+ Q+). T. or STRAIGHT THREE OF A KIND Contains three matching cards of the same rank Qe av Q7e 4* and two unmatched cards of other ranks Two PAIR Contains two cards of the same rank, plus two cards ofanother rank (that match each other but not the first pair), plus any card not of either rank T. T+ 8, 8+ A ONE PAIR Contains two cards of one rank, plus three cards4 4 Ke T+ 5e which are neither of that rank nor the same as each other HIGH CARD Five cards not meeting any of the above requirements
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
