subject

In this assignment we will work on the creation of a poker game. at a minimum your game must deal 2 hands of cards, and print out what poker hand each has. it must also determine which hand has won the game – but breaking a tie will be for bonus points. for example, if both hands have 3 of a kind, that can be considered a tie. if you want the bonus points write some code that determines which 3 of a kind is higher.

here is the output from dealing a hand of cards:

ace of hearts
ten of clubs
ace of clubs
eight of hearts
seven of diamonds

2 2 1 0 < > 0 0 0 0 0 1 1 0 1 0 0 0 2

you have a pair!

use lots of small functions to reduce the complexity of the code.
you must use the code from the video to get started, and you must use the following representation for a poker hand:
make 2 arrays: suitsinhand[4], and facesinhand[14].
suitsinhand is 4 counters that represents how many hearts, clubs, diamonds, spades are in the hand. these 4 counters must add up to 5 for a hand of 5 cards. for example if you have 5 hearts in the hand of cards, the array would have the values 5,0,0,0
facesinhand is 13 counters, that represent how many two’s, three’s, etc. you have in the hand. this must also total 5. for example, if you have a pair of 3’s, and three kings’s, this array would have the values 0,2,0,0,0,0,0,0,0,0,3,0

while dealing a hand of cards, keep a count of the suitsinhand, and facesinhand.

i will include some code below that will you to figure out what poker hand you have dealt.
this function will use the 2 arrays described above to determine if the hand has a flush, straight, etc. i have not included the parameters. you will need to pass in the hand of cards, and have the function pass back if there is a flush, straight, three of a kind, etc.

/* analyzehand: determines whether the hand contains a straight, a flush, four-of-a-kind, and/or a three-of-a-kind; determines the number of pairs; stores the results into the external variables straight, flush, four, three, and pairs. */

void analyzehand( …
{ int num_consec = 0;
int rank, suit;
straight = false;
flush = false;
four = false;
three = false;
pairs = 0;

// check for flush – 5 cards of the same suit

for (suit = 0; suit < suits; suit++)

if (suitsinhand[suit] == 5)

flush = true;

// check for straight – eg. one each of 5,6,7,8,9

// locate the first card rank = 0;

while (facesinhand[rank] == 0)

rank++;

// count the consecutive non-zero faces

for (; rank < faces & & facesinhand[rank]; rank++)

num_consec++;

if (num_consec == 5) {

straight = true;

return;

}

/* check for 4-of-a-kind, 3-of-a-kind, and pairs */

for (rank = 0; rank < num_ranks; rank++) {

if (facesinhand[rank] == 4)

four = true;

if (facesinhand[rank] == 3)

three = true;

if (facesinhand[rank] == 2)

pairs++;

}

}

here is a block of code that might you determine what hand is better than another. these are in order. a straight-flush is the best hand, and a high-card is the worst hand.

if (straight & & flush)
printf("straight flush\n\n");
else if (four)
printf("four of a kind\n\n");
else if (three & & pairs == 1)
printf("full house\n\n");
else if (flush)
printf("flush\n\n");
else if (straight)
printf("straight\n\n");
else if (three)
printf("three of a kind\n\n");
else if (pairs == 2)
printf("two pairs\n\n");
else if (pairs == 1)
printf("pair\n\n");
else printf("high card\n\n");
deliverables: 1. paste your code below, in this document.

2. include the output of running the program 10 times. include several different cases, for example 2 pair, high card. each case that you expect points for will be demonstrated in the output.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 16:00
Choice of type is influenced primarily by these two factors?
Answers: 3
question
Computers and Technology, 22.06.2019 23:30
Jaina and tomas are being considered as new tenants in an apartment. the landlord looks at their creditworthiness because he wants to be sure his new tenant pays the rent on time and in full. the table below summarizes the information that was on their applications. application information questions jaina tomas how many years have you had your job? 5 2 what is your monthly salary? $1,850 $2,500 how many credit cards do you have? 4 1 how much debt do you have? $13,000 $7,000 how many times were you late with payments on credit cards in the past year? 5 1 who will the landlord decide to be more creditworthy and why? tomas because the ratio of his debt to income is less. jaina because she has had her job longer, which makes her look more stable. jaina because she has more credit cards available to her. tomas because he makes more money per month.
Answers: 2
question
Computers and Technology, 23.06.2019 06:40
How many nibbles can be stored in a 16-bit word?
Answers: 1
question
Computers and Technology, 23.06.2019 15:00
Barbara is interested in pursuing a career in the science and math pathway. which qualifications will her reach that goal? a.an advanced knowledge of physics and math b.an advanced knowledge of engineering and math c. an advanced knowledge of physics and robotics an d. advanced knowledge of machinery and math
Answers: 2
You know the right answer?
In this assignment we will work on the creation of a poker game. at a minimum your game must deal 2...
Questions
question
Chemistry, 02.07.2019 00:10
Questions on the website: 13722363