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, 23.06.2019 01:30
Which tab is used to change the theme of a photo album slide show? a. design b. view c. transitions d. home
Answers: 1
question
Computers and Technology, 23.06.2019 18:50
What is transmission control protocol/internet protocol (tcp/ip)? software that prevents direct communication between a sending and receiving computer and is used to monitor packets for security reasons a standard that specifies the format of data as well as the rules to be followed during transmission a simple network protocol that allows the transfer of files between two computers on the internet a standard internet protocol that provides the technical foundation for the public internet as well as for large numbers of private networks
Answers: 2
question
Computers and Technology, 23.06.2019 19:30
Amitha writes up a one-page summary of a novel during her summer internship at a publishing company. when she reads over the page, she realizes she used the word “foreshadow” seven times, and she would like to reduce the repetition. which tool would best amitha solve this problem?
Answers: 3
question
Computers and Technology, 24.06.2019 02:10
Consider the usual algorithm to convert an infix expression to a postfix expression. suppose that you have read 10 input characters during a conversion and that the stack now contains these symbols: (5 points) | | | + | | ( | bottom |_*_| now, suppose that you read and process the 11th symbol of the input. draw the stack for the case where the 11th symbol is
Answers: 2
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
Physics, 16.08.2020 01:01
Questions on the website: 13722363