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 17:40
Consider the simple 3-station assembly line illustrated below, where the 2 machines at station 1 are parallel, i.e., the product only needs to go through one of the 2 machines before proceeding to station 2.what is the throughput time of this process?
Answers: 2
question
Computers and Technology, 22.06.2019 22:00
What is the name of the option in most presentation applications with which you can modify slide elements? 1. the option enables you to modify a slide element in most presentation applications.
Answers: 3
question
Computers and Technology, 23.06.2019 11:50
While preforming before operation pmcs, you notice the front right tire appears slightly under-inflated. what is the proper action?
Answers: 3
question
Computers and Technology, 24.06.2019 21:00
When replacing a thermostat or water pump, coolant drained from the cooling system should be
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, 31.03.2020 21:56
question
English, 31.03.2020 21:56
question
Mathematics, 31.03.2020 21:56
question
English, 31.03.2020 21:56
question
Mathematics, 31.03.2020 21:56
question
Mathematics, 31.03.2020 21:56
question
History, 31.03.2020 21:56
question
Mathematics, 31.03.2020 21:56
question
Mathematics, 31.03.2020 21:56
Questions on the website: 13722362