Starting from:

$24

Poker Hand

Write a program that reads five cards from the user, then analyzes the cards and prints out the category of hand that they represent. Poker hands are categorized according to the following labels: Straight flush, four of a kind, full house, flush, straight, three of a kind, two pairs, pair, high card.To simplify the program we will ignore card suits, and face cards. The values that the user inputs will be integer values from 2 to 9. When your program runs it should start by collecting five integer values from the user. It might look like this (user input is in orange for clarity):Enter five numeric cards, no face cards. Use 2 - 9.Card 1: 8 Card 2: 7Card 3: 8Card 4: 2Card 5: 3(This is a pair, since there are two eights)Since we are ignoring card suits there won’t be any flushes. Your program should be able to recognize the following hand categories, listed from least valuable to most valuable:(A note on straights: a hand is a straight regardless of the order. So the values 3, 4, 5, 6, 7 represent a straight, but so do the values 7, 4, 5, 6, 3)Your program should read in five values and then print out the appropriate hand type. If a hand matches more than one description, the program should print out the most valuable hand type.Here is are two sample runs of the program:Enter five numeric cards, no face cards. Use 2 - 9.Card 1: 8 Card 2: 7Card 3: 8Card 4: 2Card 5: 7Two Pair!Enter five numeric cards, no face cards. Use 2 - 9.Card 1: 4 Card 2: 5Card 3: 6Card 4: 8Card 5: 7Straight!Enter five numeric cards, no face cards. Use 2 - 9.Card 1: 9Card 2: 2Card 3: 3Card 4: 4Card 5: 5High Card!RequirementsYou must write a method for each hand type. These methods are the main work of the assignment. Each method should accept an int array. You can assume that the array will have five elements. The methods should have the following signatures. public static boolean containsPair(int hand[])public static boolean containsTwoPair(int hand[])public static boolean containsThreeOfaKind(int hand[])public static boolean containsStraight(int hand[])public static boolean containsFullHouse(int hand[])public static boolean containsFourOfaKind(int hand[])You do not need to write a containsHighCard method. All hands contain a highest card. If you determine that a particular hand is not one of the better hand types, then you know that it is a High Card hand.SuggestionsTest these method independently. Once you are sure that they all work, the program logic for the complete program will be fairly straightforward.Here is code that tests a containsPair method:public class PokerHands { public static void main(String args[]) { int hand[] = {5, 2, 2, 3, 8}; if (containsAPair(hand)) { System.out.println("Pair!"); } else { System.out.println("Not a pair!"); } } public static boolean containsAPair(int hand[]) { // Your code here... don’t return true every time... return true; }}

More products