Question: Write code in C++ Write a program that analyzes a poker hand for 5 card stud. The following link may be helpful if you are

Write code in C++Write code in C++ Write a program that analyzes a poker handfor 5 card stud. The following link may be helpful if youare a bit unfamiliar with poker rules: http://en.wikipedia.org/wiki/List_of_poker_hands For this program, assume

Write a program that analyzes a poker hand for 5 card stud. The following link may be helpful if you are a bit unfamiliar with poker rules: http://en.wikipedia.org/wiki/List_of_poker_hands For this program, assume there are no jokers, and the highest hand possible is a Royal Flush, which is a Straight Flush with an Ace High. Hands in order of decreasing value are thus: Royal Flush Straight Flush Four of a Kind Full House Flush Straight Three of a Kind Two Pairs One Pair High Card Specifications: Split your program into three functions: void readCards(void); // Read in 5 cards, Ignoring Bad/Repeated Cards void analyzeHand(void); // Analyze cards for Different Hands to Play void printResults(void); // Print the Best Hand Because all three functions are void functions, we will use a number of global constants and variables: Global Constants NUM_RANKS // Stores number of ranks in a deck (13) NUM_SUITS // Stores number of suits in a deck (4) NUM_CARDS // Stores number of cards to be played (5) Global Variables int numInRank[NUM_RANKS] // Array representing the number of a given rank in hand // numInRank[0] represents number of 2s // numInRank[1] represents number of 3s // // numInRank[12] represents number of Aces int numInSuit[NUM_SUITS] // Array representing the number of a given suit in hand // numInSuit[0] represents number of Clubs // numInSuit[1] represents number of Diamonds // numInSuit[2] represents number of Hearts // numInSuit[3] represents number of Spades bool Royal // Set true if player has a Royal Flush bool Flush // Set true if player has a Flush bool Straight // Set true if player has a Straight bool Four // Set true if player has Four of a Kind bool Three // Set true if player has Three of a Kind int Pairs // Counts number of Pairs in Hand Finally, a 2D Boolean array called cardExists[NUM_RANKS][NUM_SUITS] will be needed to be used in the readCards() function to keep track of which cards have been successfully entered into the program. The row represents the rank of the card (2 through Ace), and the column the suit (Clubs, Diamonds, Hearts, and Spades in that order!). A given element in the 2D array should be set to true whenever a card is successfully read into the program. Assume the input is a number of letter representing the rank (2, 3, 4, 5, 6, 7, 8, 9, T, J, Q, K, A), followed by a letter for the suit (C, D, H, S). Letters may be input lowercase or uppercase. The appropriate element in the numInRank[] array should be incremented every time a given rank is input into the program. Force instance, if the 3 of Hearts and the 3 of Diamonds are input, numInRank[1] will be 2, since there are 2 3s in your hand. Likewise, the appropriate element in the numInSuit[] array should be incremented every time a given suit is input into the program. In the previous example, numInSuit[1] = 1 and numInSuit[2] = 1, since the order of the suits are Clubs, Diamonds, Hearts, and Spades. As cards are successfully read in, each of these arrays should be adjusted, as appropriate. Once the cards are read in, the numInRank[] and numInSuit[] arrays can be used to determine your possible hands (i.e. if you have a straight, a flush, 3 of a Kind, etc.) within the analyzeHand() function. The appropriate global variables should be set as appropriate. Finally, the printResults function can analyze these variables to determine your best hand. If you have a straight and a flush, but not Ace high, then your best hand is a Straight Flush. If you execute the program, the following information should be displayed: ~> main.o Welcome to the 5 Card Stud Analyzer Program Enter Card 1: 3hasdfa Ignoring bad card. Enter Card 1: h3 Ignoring bad card. Enter Card 1: 3h Enter Card 2: 4H Enter Card 3: 4d Enter Card 4: 7h Enter Card 5: 8C Best Hand: One Pair ~> main.o Welcome to the 5 Card Stud Analyzer Program Enter Card 1: KC Enter Card 1: QC Enter Card 1: QC Ignoring duplicate card. Enter Card 3: JC Enter Card 4: AC Enter Card 5: TC Best Hand: Royal Flush

Write a program that analyzes a poker hand for 5 card stud. The following link may be helpful if you are a bit unfamiliar with poker rules For this program, assume there are no jokers, and the highest hand possible is a "Royal Flush", which is a Straight Flush with an Ace High. Hands in order of decreasing value are thus: Royal Flush Straight Flush Four of a Kind Full House Flush Straight Three of a Kind Two Pairs One Pair High Card Specifications: Split your program into three functions void readCards(void); // Read in 5 cards, Ignoring Bad/Repeated Cards void analyzeHand( void); ll Analyze cards for Different Hands to Play void printResults(void) I/ Print the Best Hand Because all three functions are void functions, we will use a number of global constants and variables: Global Constants NUM RANKS NUM SUITS NUM CARDS I/ Stores number of ranks in a deck (13) IlIl Stores number of suits in a deck (4) Il Stores number of cards to be played

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!