Answered step by step
Verified Expert Solution
Question
1 Approved Answer
CS 1 1 1 B Assignment: Pairs and Straights Write a program that reads five integer values from the user, then analyzes them as if
CSB Assignment: Pairs and Straights
Write a program that reads five integer values from the user, then analyzes them as if they were a hand of cards. When your program runs it might look like this user input is in orange for clarity:
Enter five numeric cards, no face cards. Use
Card :
Card :
Card :
Card :
Card :
Pair!
This is a pair, since there are two eights
Here is a table that shows the different possible types of hands, with an example of each. You are only required to find the hands Pair and Straight. Feel free to work on the others if you are interested.
Required Hands
Description
Example
High Card
If the hand is not a straight, and there are no matches then it is simply called a "high card" hand.
Pair required
Two of the cards are identical
Straight required
A sequence of values with no matches and no gaps. They do not need to be in order
Optional Hands
Description
Example
Two Pair
Two different pairs
Three of a kind
Three matching cards
Full House
A pair, and a three of a kind
Four of a kind
Four matching cards
A note on straights: a hand is a straight regardless of the order. So the values represent a straight, but so do the values
Your program should read in five values and then print out either "Straight", "Pair", or "High Card".
What to Submit
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