Write a C++ program that inputs three integers in the range [1..13] that represent a hand...

70.2K

Verified Solution

Question

Programming

Write a C++ program that inputs three integers in the range[1..13] that represent a hand of three cards. Your program shouldoutput an English evaluation of the hand.

In the output, cards will be described as follows:

- 2–10 are described by the words for their numeric values: two,three, etc.

- 1 is called an ace, 11 is called a jack, 12 is called a queen,and 13 is called a king.

The evaluation of a hand is based on the first of the followingcases that matches the cards:

- All three cards are equal to each other.

Sample output for 4 4 4: You have three fours.

- The three cards form a straight (three successive values).

Sample output for 6 8 7: You have an eight-high straight.

- Two cards (a pair) are equal.

Sample output for 6 3 6: You have a pair of sixes.

- Whatever is the highest card.

Sample output for 11 1 8: You have a jack.

Recommend sorting the card values before trying to evaluate thehand –that makes it much easier. Also, work on one thing at a time:first determine what kind of hand (3 of kind, 2 of kind,straight,...) and then determine what is the “significant” card forthat hand (it becomes very messy and exhausting if you try to doboth at the same time!). Check for card values being equal to eachother (card1 == card2), not specific values (card1 == 1 &&card2 == 1 || card1 == 2 && card 2 == 2 || ...). If youcheck each value, your program will be hundreds of lines long!

Answer & Explanation Solved by verified expert
4.3 Ratings (578 Votes)
Here is the C code to the given questionSample outputs are added at the endCodeinclude    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students