Question
Write a program in C++ That reads five cards from the user, then analyzes the cards and prints out the category of poker hand that
Write a program in C++
That reads five cards from the user, then analyzes the cards and prints out the category of poker 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, aces, 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. It might look like this (user input is in orange for clarity):
Enter five numeric cards, no face cards. Use 2 - 9.
Card 1: 8
Card 2: 7
Card 3: 8
Card 4: 2
Card 5: 3
Requirements
You must write a function for each hand type. Each function must accept an int array as a parameter. You can assume that the array will have five elements. The functions should have the following signatures:
bool containsPair(int hand[])
bool containsTwoPair(int hand[])
bool containsThreeOfaKind(int hand[])
bool containsStraight(int hand[])
bool containsFullHouse(int hand[])
bool containsFourOfaKind(int hand[])
You do not need to write a containsHighCard function. All hands contain a highest card. If you determine that a particular hand is not one of the better hand types, then you know that it is a High Card hand.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started