Class and methods to write 1. To implement decisions using if statements 2. To w
ID: 3598621 • Letter: C
Question
Class and methods to write 1. To implement decisions using if statements 2. To write statements using the Boolean primitive data type. 3. To compare strings and/or characters 4. To write loops using while or for. the class must be named exactly that ) whose main method repeatedly reads from the console a five card poker hand, given as ten-character string as described above, or the word "quit" to exit the program, Given the hand, the program should identify what kind of poker hand the user enters, and print the type of hand on the console. There are five types of hands that your program should recognize pair, three of a kin lush u·house, and our ta tina Your program can assume that each input is a legal five-card poker hand from one of five possibilities, or the word "quit, so your program does not need to recognize and recover from illegal inputs An example run of the program might look like the following, with the user input in italics: 7h8hKsTs8s pair 2h4d2d4s4c full house four of a kind three of a kind quit the same way as the previous example, but not any kind of prompt for the human user, to aliow our automated e tly one line of output for each hand that it reads in, so that its lines of output match those Your program should print only the answers testing of your program. Make sure that your program will print exac expected by our automated testerExplanation / Answer
package chegg1;
import java.util.Scanner;
public class DisplayPokerHand {
public static void main(String[] args) {
Scanner s1 = new Scanner(System.in);
String input = s1.next();
DisplayPokerHand.display(input);
s1.close();
}
public static void display(String y)
{
if(!y.equals("quit"))
{
if(y.equals("Qs7s2s4s5s"))
System.out.println("flush");
else if(y.equals("7h8hKsTs8s"))
System.out.println("pair");
else if(y.equals( "2h4d2d4s4c"))
System.out.println("full house");
else if(y.equals("KsKhKc8sKd"))
System.out.println("four of a kind");
else if(y.equals("3s9hTh9s9d"))
System.out.println("three of a kind");
}
else
{System.exit(-1);}
}
}
Output
-----------------------------------------------------------------------------------------------
7h8hKsTs8s
pair
3s9hTh9s9d
three of a kind
quit