P: 1 | I just started programming in C, and I need some help with this problem. Your program will read the information about one MiniPoker hand, namely the rank and suit of the hand’s first card, and the rank and suit of its second card. Note that the two cards in a hand may be entered in any order; it’s not necessarily the case that the highest card will appear first, for example. Your program will then determine whether the hand is valid, and classify the hand as to what type it is. Your program should first print a message asking its user to enter the necessary input data, and should then read four pieces of information from the input. The information to be read is specifically as follows: 1 1. The first piece of information to be read from the input is an integer which should represent the rank of the first card in the hand: • The numbers 2 through 10 indicate that indicates the first card is a two through a ten, respectively. • The number 11 indicates that indicates the first card is a jack. • The number 12 indicates that indicates the first card is a queen. • The number 13 indicates that indicates the first card is a king. • The number 14 indicates that indicates the first card is an ace. 2. The second piece of information to be read from the input is a single letter which should indicate the suit of the first card in the hand: • An uppercase C indicates the first card is a club. • An uppercase D indicates the first card is a diamond. • An uppercase H indicates the first card is a heart. • An uppercase S indicates the first card is a spade. 3. The third piece of information to be read from the input is an integer which should represent the rank of the second card in the hand, which follows the same rules as that of the rank of the first card above. 4. The fourth piece of information to be read from the input is a letter which should represent the suit of the second card in the hand, which follows the same rules as that of the suit of the first card above. These four data items will always be separated from each other by at least one whitespace character (a blank, tab, or newline), but arbitrary additional whitespace may optionally appear before or after these input data items, or in between them. 2.2 Program output After analyzing the two cards forming the hand, your program should print a single output line containing one and only one of the following phrases. The phrases for valid MiniPoker hands are listed first, before the phrases to be printed for incorrect hands. 1. Your program should print a line containing one of the exact phrases “two high”, “three high”, “four high”, “five high”, “six high”, “seven high”, “eight high”, “nine high”, “ten high”, “jack high”, “queen high”, “king high”, or “ace high”, indicating the rank of the highest card in the hand, if the hand doesn’t fall into any of the categories below. Note that this is the lowest type of card hand. 2. Your program should print a line containing one of the exact phrases “pair of twos”, “pair of threes”, “pair of fours”, “pair of fives”, “pair of sixes”, “pair of sevens”, “pair of eights”, “pair of nines”, “pair of tens”, “pair of jacks”, “pair of queens”, “pair of kings”, or “pair of aces”, depending upon the cards’ ranks, if the two cards in the pair have the same rank. (The cards’ suits don’t matter, except that they should not be identical, otherwise the hand would be of a a different type described below.) This is the second–lowest type of card hand. 3. Your program should print a line containing the exact phrase “straight” if the two cards in the pair form a (simple) straight, meaning that their ranks have adjacent value, but their suits aren’t the same. For example, a hand with a four of clubs and a five of diamonds is a straight, as is a hand with a queen of diamonds and a king of hearts. 4. Your program should print a line containing the exact word “flush” if the two cards in the pair form a flush. A hand is a (simple) flush when the two cards’ suits are the same, but their ranks are not the same and also don’t have adjacent values, and they are not royalty. (Note that if the two cards’ suits were the same and their ranks were the same or had adjacent values, or the cards were royalty, the hand would be one of the three special flush types below.) 2 5. Your program should print a line containing the exact phrase “straight flush” if the two cards in the pair form a straight flush, which is a flush in which the two cards’ ranks also have adjacent values (the cards form both a straight as well as a flush). 6. Your program should print a line containing the exact phrase “royal flush” if the two cards in the pair form a flush in which both cards are royalty. 7. Your program should print a line containing the exact phrase “royal straight flush” if the two cards in the pair form a flush in which the two cards’ ranks have adjacent values and both cards are royalty. Note that this is the highest type of card hand. Although there is some overlap in the conditions describing the hand types, your program must identify the most specific or highest type of hand represented by two cards. For example, if the hand read consisted of an eight of spades and a nine of spades, they form a straight, as well as a flush, as well as a straight flush, so since a straight flush is the highest of these three hand types that is considered the type of this hand. Note also that since the conditions overlap, the words in the phrases above also do to some extent, but the messages your program prints must categorize each hand type exactly, and not also describe any other hand type. For example, if the hand read consisted of a five of diamonds and a ten of diamonds, the description above says “your program should print a line containing the exact word ‘flush’ ”, but the message printed must contain only the word “flush”, not the phrases “straight flush”, “royal flush”, or “royal straight flush”. Note that as the syllabus discusses, your program can print additional information on the output lines (for example, see the sample output section below), as long as they contain the required words or phrases. The phrases to be printed if your program detects that the poker hand is incorrect are: 1. Your program should print a line containing the exact phrase “first card is invalid” if the first card is incorrect in any way (i.e., either its rank or suit is incorrect). 2. Your program should print a line containing the exact phrase “second card is invalid” if the second card is incorrect in any way. 3. Your program should print a line containing the exact phrase “cards are identical” if the two cards are the same. Since a deck of cards doesn’t have any duplicates, something is wrong if a MiniPoker hand contains two of the same cards. If any input line contains more than one of the errors described, your program can print any one (and only one) of the error phrases, at your option |