subject
Computers and Technology, 14.12.2019 03:31 loridoz

In order to discover that a poker hand has a straight, you must first search for the lowest card in the hand, then you must search for the next higher card, the card higher than that, and so on. for example, if the lowest card is a four, you must next search for a 5 in the hand, then a six, then a seven, and finally an eight. if any of these searches fails, then the card does not contain a straight.

note that a "wrap straight", which is defined as a straight that includes both a king and an ace by wrapping around the top of the card hierarchy is not considered a legitimate straight. therefore finding the lowest card and searching upwards is guaranteed to determine if a straight exists. this is not precisely the rule in all card games, but we will hold to it here to focus on the objective of the lesson.

the cards are to be represented using the numbers 0-51, where 0-12 are the diamonds, 13-25 are the clubs, 26-38 are the hearts, and the rest are the spades. in each suit, the lowest number is to correspond to the ace, the next lowest is the 2, and so on up until you reach the jack, queen and the king. a 5 card hand is to be represented as an array with 5 integers where no two can be the same. you should generate it by selecting the first 5 integers from a shuffled array of all 52 integers above. see lecture slides on shuffling an array.

step 1: write a method to generate a shuffled deck of cards represented as an array of 52 integers.

step 2: write a method that draws the first 5 card hand from a shuffled deck, represented as the first 5 cards in the array.

step 3: write a method that accepts a 5 card hand and an integer k as input. it should search for the kth lowest card. so if k is 1, it searches for the lowest card. if k is 2, it searches for the second lowest card, etc. if k is greater than 5 or less than zero, it returns an error. use linear search.

finally, write a method that calls the method in step 3 to search for your straight.

integrate straight() into a new main method that generates random hands. call straight() to determine if the random hands have a straight. perform this test on one million randomly generated hands, counting how frequently a straight is detected. according to wikipedia, the chance of drawing a straight is 0.3925%. your randomly generated hands are simulating this probability - do you observe the same percentage?

write your code in straight. java.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 11:00
Eva has many contacts on the professional networking site she uses which contacts are considered second degree
Answers: 3
question
Computers and Technology, 22.06.2019 11:00
You receive an email from an impressive-sounding stranger, professor alexander rothschild renard iii, president of the american institute for scientific political statesmen. he urges you to vote for his presidential candidate choice. this social media red flag is known as
Answers: 1
question
Computers and Technology, 23.06.2019 20:00
How much current flows through the alternator brushes? a. 2–5 a b. 25–35 a, depending on the vehicle c. 5–10 a d. 10–15 a
Answers: 2
question
Computers and Technology, 23.06.2019 23:00
Lucas put a lot of thought into the design for his company's new white paper. he made sure to include repeating design elements such as color schemes and decorative images. his goal was to a.add symmetry b.create a unified publication c.provide consistency d.save money
Answers: 1
You know the right answer?
In order to discover that a poker hand has a straight, you must first search for the lowest card in...
Questions
question
Mathematics, 18.10.2019 04:30
question
Chemistry, 18.10.2019 04:30
Questions on the website: 13722363