Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program in c++ that plays simplified poker game with the computer. Ask the user to input an integer in the range [1, 13],

Write a program in c++ that plays simplified poker game with the computer.

Ask the user to input an integer in the range [1, 13], representing a simplified poker card with no suit (1: A, 11: J, 12: Q; 13: K). Then the computer generates four random integers in the same range, together with the user input, as five poker

cards for the user.

The computer generates another set of five random integers as the poker cards for

the computer. Each one is also in the range [1, 13].

Your program should then compare the highest ranking of the 5 hands between user and the computer, then report the one, who has higher ranking of the 5 hands, wins the game. Here is the rule to decide the highest ranking of the 5 hands (from higher to lower ranking) namely, Four of a Kind(4 of the 5 cards are equal), Full House(three cards are equal of one rank, and two cards are equal of another rank), Three of a Kind(any 3 cards are equal), Pair(any 2 cards are equal), and High Card(no two cards are equal). For example, when 3, 1, 8, 1, 3 are entered, your program should print Pair(1). (Note that 1 is higher than 3 since 1 represents A in the card.) When 2, 11, 7, 3, 5 are entered, it will print High(11). When 10, 7, 10, 7, 7 are entered, it will print Full House(7). (Note if it is a Full House, report the rank of three matching cards instead of the rank of two matching cards). An you dont need to consider other rankings such as Straight or Flush. When the user and the computer have the same kind of the 5 hands, then the higher value of the card has the higher ranking. For example, if both have Full House, then Full House(12) is higher than Full House(11).

Note the real poker game contains 52 cards in a deck, divided into four suits of 13 ranks each, so that it can never happen that five cards are equal. However, since your program uses the random number generator to generate five cards (no suite), five can be equal. In order to avoid this case (five cards happen to be the same), your program should generate four cards first, then while generating the fifth card, it needs to check whether the fifth card has already been in the hand four times. If it is the case, then generate a different card.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David M. Kroenke

12th Edition International Edition

1292023422, 978-1292023427

More Books

Students also viewed these Databases questions

Question

Why is the System Build Process an iterative process?

Answered: 1 week ago