Computers and Technology
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.

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 19:30, 710jonathan
The following is an excerpt from a slide presentation. today we will inverse operations solving equations using inverse operations solving inequalities using inverse operations from which part of the presentation does the slide most likely come from? a. introduction b. outline c. body d. conclusion
Answers: 1
image
Computers and Technology, 22.06.2019 20:00, jc624826
What side length would you specify if you were required to create a regular hexagonal plate that was composed of 33 cm(squared) of sheet metal? dimension the side length to 0.1 cm
Answers: 2
image
Computers and Technology, 23.06.2019 13:30, powellmj9216
Spoons are designed to be used for: spring hammering. applying body filler. identifying high and low spots. sanding highly formed areas.
Answers: 3
image
Computers and Technology, 23.06.2019 20:30, batmandillon21
1. for which of the following are you not required to signal beforehand? a. changing lanes b. speeding up c. stopping
Answers: 2
Do you know the correct answer?
In order to discover that a poker hand has a straight, you must first search for the lowest card in...

Questions in other subjects: