Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ program that reads five cards from the user, then analyzes the cards and prints out the category of hand that they represent.

image text in transcribed
image text in transcribed
image text in transcribed
Write a C++ program that reads five cards from the user, then analyzes the cards and prints out the category of hand that they represent. Poker hands are categorized according to the following labels: Straight flush, four of a kind, full house, straight, flush, three of a kind, two pairs, pair, high card. To simplify the program we will ignore card suits, and face cards. The values that the user inputs will be integer values from 2 to 9. When your program runs it should start by collecting five integer values from the user and placing the integers into an array that has 5 elements. It might look like this: Enter five numeric cards, no face cards. Use 2-9 Card 1: 8 Card 2: 7 Card 3: 8 Card 4: 2 Card S: 3 (This is a pair, since there are two eights) Since we are ignoring card suits there won't be any flushes. Your program should be able to recognize the following hand categories, listed from least valuable to most valuable: Hand Type Description gh CardThere are no matching cards, and the hand is not a straight Pair Two Pair Three of a kind Straight Full House Four of a kind Example 2,5, 3,8,7 2,5,3.5,7 2,5.3, 5,3 5, 5,3,5,7 3.5,6.4,7 5.7,5.7,7 2, 5, 5.5.5 Hi Two of the cards are identical Two different pairs Three matching cards 5 consecutive cards A pair and three of a kind Four matching cards (A note on straights: a hand is a straight regardless of the order. So the values 3, 4,5,6,7 represent a straight, but so do the values 7,4,5,6,3). Your program should read in five values and then print out the appropriate hand type. If a hand matches more than one description, the program should print out the most valuable hand type. Write a C++ program that reads five cards from the user, then analyzes the cards and prints out the category of hand that they represent. Poker hands are categorized according to the following labels: Straight flush, four of a kind, full house, straight, flush, three of a kind, two pairs, pair, high card. To simplify the program we will ignore card suits, and face cards. The values that the user inputs will be integer values from 2 to 9. When your program runs it should start by collecting five integer values from the user and placing the integers into an array that has 5 elements. It might look like this: Enter five numeric cards, no face cards. Use 2-9 Card 1: 8 Card 2: 7 Card 3: 8 Card 4: 2 Card S: 3 (This is a pair, since there are two eights) Since we are ignoring card suits there won't be any flushes. Your program should be able to recognize the following hand categories, listed from least valuable to most valuable: Hand Type Description gh CardThere are no matching cards, and the hand is not a straight Pair Two Pair Three of a kind Straight Full House Four of a kind Example 2,5, 3,8,7 2,5,3.5,7 2,5.3, 5,3 5, 5,3,5,7 3.5,6.4,7 5.7,5.7,7 2, 5, 5.5.5 Hi Two of the cards are identical Two different pairs Three matching cards 5 consecutive cards A pair and three of a kind Four matching cards (A note on straights: a hand is a straight regardless of the order. So the values 3, 4,5,6,7 represent a straight, but so do the values 7,4,5,6,3). Your program should read in five values and then print out the appropriate hand type. If a hand matches more than one description, the program should print out the most valuable hand type

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started