Write a program 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 bold red 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 (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 Example High Card There are no matching cards, and the hand is not a straight 2, 5, 3, 8, 7 Pair Two of the cards are identical 2, 5, 3, 5, 7 Two Pair Two different pairs 2, 5, 3, 5, 3 Three of a kind Three matching cards 5, 5, 3, 5, 7 Straight Card values can be arranged in order 3, 4, 5, 6, 7 Full House A pair, and a three of a kind 5, 7, 5, 7, 7 Four of a kind Four matching cards 2, 5, 5, 5, 5 A note on straights: a hand is a straight regardless of the order. So the values 3, 4, 5, 6, 7 represent a straight; 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 only. Here are three sample runs of the program (user input in bold red): Enter five numeric cards, no face cards. Use 2 - 9. Card 1: 8 Card 2: 7 Card 3: 8 Card 4: 2 Card 5: 7 Two Pair! Enter five numeric cards, no face cards. Use 2 - 9. Card 1: 8 Card 2: 7 Card 3: 4 Card 4: 6 Card 5: 5 Straight!Enter five numeric cards, no face cards. Use 2 - 9. Card 1: 9 Card 2: 2 Card 3: 3 Card 4: 4 Card 5: 5 High Card! 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[])

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

***PLEASE LOOK AT IMAGES AS WELL FOR HELP***

Write a program 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 bold red 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

(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

Example

High Card

There are no matching cards, and the hand is not a straight

2, 5, 3, 8, 7

Pair

Two of the cards are identical

2, 5, 3, 5, 7

Two Pair

Two different pairs

2, 5, 3, 5, 3

Three of a kind

Three matching cards

5, 5, 3, 5, 7

Straight

Card values can be arranged in order

3, 4, 5, 6, 7

Full House

A pair, and a three of a kind

5, 7, 5, 7, 7

Four of a kind

Four matching cards

2, 5, 5, 5, 5

A note on straights: a hand is a straight regardless of the order. So the values 3, 4, 5, 6, 7 represent a straight; 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 only.

Here are three sample runs of the program (user input in bold red):

Enter five numeric cards, no face cards. Use 2 - 9.
Card 1: 8
Card 2: 7
Card 3: 8
Card 4: 2
Card 5: 7
Two Pair!
Enter five numeric cards, no face cards. Use 2 - 9.
Card 1: 8
Card 2: 7
Card 3: 4
Card 4: 6
Card 5: 5
Straight!Enter five numeric cards, no face cards. Use 2 - 9.
Card 1: 9
Card 2: 2
Card 3: 3
Card 4: 4
Card 5: 5
High Card!

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.

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.
Suggestions
Test these functions independently. Once you are sure that they all work, the program logic for the complete program
will be fairly straightforward.
Here is code that tests a containsPair function:
int main() {
int hand[] = {2, 5, 3, 2, 9};
if (containsPair(hand)) (
cout <« "Pair!" <« endl;
return e;
You can use a main function like this to test each function with different input arrays until you are confident that your
logic is correct.
Transcribed Image Text: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. Suggestions Test these functions independently. Once you are sure that they all work, the program logic for the complete program will be fairly straightforward. Here is code that tests a containsPair function: int main() { int hand[] = {2, 5, 3, 2, 9}; if (containsPair(hand)) ( cout <« "Pair!" <« endl; return e; You can use a main function like this to test each function with different input arrays until you are confident that your logic is correct.
Write a program 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 bold red for clarity):
Enter five nureric cards, no face cards. Use 2 - 9.
Card 1: 8
Card 2: 7
Card 3: в
Card 4: 2
Card 5: 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
Example
High Card
There are no matching cards, and the hand is not a straight 2, 5, 3, 8, 7
Pair
Two of the cards are identical
2, 5, 3, 5, 7
Two Pair
Two different pairs
2, 5, 3, 5, 3
Three of a kind Three matching cards
5, 5, 3, 5, 7
Straight
Card values can be arranged in order
3, 4, 5, 6, 7
Full House
A pair, and a three of a kind
5, 7, 5, 7,7
Four of a kind Four matching cards
2, 5, 5, 5, 5
A note on straights: a hand is a straight regardless of the order. So the values 3, 4, 5, 6. 7 represent a straight; 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 only.
Here are three sample runs of the program (user input in bold red):
Enter five nureric cards, no fac cards. Use 2 - 9.
Card 1: 8
Card 2: 7
Card 3: 8
Card 4: 2
Card 5: 7
Two Pairl
Enter five nureric cards, no face cards. Use 2 - 9.
Card 1: 8
Card 2: 7
Card 3: 4
Card 4: 6
Card 5: 5
Straight!
Enter five nureric cards, no face cards. Use 2 - 9.
Card 1: 9
Card 2: 2
Card 3: 3
Card 4: 4
Card 5: 5
High Cardl
Transcribed Image Text:Write a program 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 bold red for clarity): Enter five nureric cards, no face cards. Use 2 - 9. Card 1: 8 Card 2: 7 Card 3: в Card 4: 2 Card 5: 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 Example High Card There are no matching cards, and the hand is not a straight 2, 5, 3, 8, 7 Pair Two of the cards are identical 2, 5, 3, 5, 7 Two Pair Two different pairs 2, 5, 3, 5, 3 Three of a kind Three matching cards 5, 5, 3, 5, 7 Straight Card values can be arranged in order 3, 4, 5, 6, 7 Full House A pair, and a three of a kind 5, 7, 5, 7,7 Four of a kind Four matching cards 2, 5, 5, 5, 5 A note on straights: a hand is a straight regardless of the order. So the values 3, 4, 5, 6. 7 represent a straight; 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 only. Here are three sample runs of the program (user input in bold red): Enter five nureric cards, no fac cards. Use 2 - 9. Card 1: 8 Card 2: 7 Card 3: 8 Card 4: 2 Card 5: 7 Two Pairl Enter five nureric cards, no face cards. Use 2 - 9. Card 1: 8 Card 2: 7 Card 3: 4 Card 4: 6 Card 5: 5 Straight! Enter five nureric cards, no face cards. Use 2 - 9. Card 1: 9 Card 2: 2 Card 3: 3 Card 4: 4 Card 5: 5 High Cardl
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education