Write a Java program that reads 5 integers, each of which is in the range of 1 and 13 representing a simplified poker card with no suit. Your program should then print the ranking of the hand with card number(s) besides the ranking. The rankings to determine are Four of a Kind(4 of the 5 cards of the same rank), Full House(3 of the 5 cards of the same rank, and 2 cards of another rank), Straight(5 cards of sequential rank), Three of a Kind(only 3 cards of the same rank), Two Pair(2 cards of the same rank, 2 cards of another rank, and no card of either rank), One Pair(only 2 of 5 cards are of the same rank), and High Card(no two cards of the same rank). Some sample runs are:
input: 2, 3, 2, 2, 2; output: Four of a Kind(2)
input: 2, 3, 2, 3, 2; output: Full House(2, 3)
input: 2, 3, 4, 5, 1; output: Straight(5)
input: 1, 13, 11, 10, 12; output: Straight(1)
input: 2, 3, 2, 2, 4; output: Three of a Kind(2)
input: 1, 9, 8, 9, 1; output: Two Pair(1, 9)
input: 2, 9, 8, 9, 2; output: Two Pair(9, 2)
input: 3, 9, 8, 9, 1; output: One Pair(9)
input: 2, 10, 7, 12, 5; output: High Card(12)
input: 2, 1, 7, 12, 5; output: High Card(1)
hint: sort the cards before checking.
CODE:


OUTPUT;


Raw_Code:
import java.util.Scanner; //importing Scanner to
take input
public class Cards{
//Declaring Cards Class
public static void main(String[] args){
Scanner input = new
Scanner(System.in);
int i,n1=0,n2=0;
int[] arr = new int[6];
//Array to take input
int[]
count={0,0,0,0,0,0,0,0,0,0,0,0,0}; //Array to find
count of each card
System.out.print("Input:");
for(i=0;i<5;i++){
arr[i] =
input.nextInt(); //Loop to take
input
int num = arr[i]
;
count[num-1]++;
//Incrementing the count of that card
}
int
count_fours=0,count_threes=0,count_twos=0,count_ones=0;
for(i=0;i<13;i++){
//Checking how many cards repeated how many
times
if(count[i] ==
4){
count_fours++;
}
else if(count[i]
== 3){
count_threes++;
}
else if(count[i]
== 2){
count_twos++;
}
else if(count[i]
== 1){
count_ones++;
}
}
if(count_fours==1 &&
count_ones==1){ //Each Condition
according to the Condition given
for(i=0;i<13;i++){
if(count[i]==4){
System.out.println("Output:Four of a Kind("+(i+1)+")");
break;
}
}
}
else if(count_threes==1 &&
count_twos==1){
for(i=0;i<13;i++){
if(count[i]==3){
n1=i+1;
}
if(count[i]==2){
n2=i+1;
}
}
System.out.println("Output:Full House(" + n1 + "," + n2
+")");
}
else if(count_threes==1 &&
count_ones==2){
for(i=0;i<13;i++){
if(count[i]==3){
System.out.println("Output:Three of a Kind("+(i+1)+")");
break;
}
}
}
else if(count_twos==2 &&
count_ones==1){
System.out.print("Output:Tow Pair(");
for(i=0;i<13;i++){
if(count[i]==2){
System.out.print(i+1 +
",");
}
}
System.out.println(")");
}
else if(count_twos==1 &&
count_ones==3){
for(i=0;i<13;i++){
if(count[i]==2){
System.out.println("Output:One Pair("+(i+1)+")");
break;
}
}
}
else if(count_ones==5){
int
flag=0;
for(i=12;i>=0;i--){
if(count[i]==1){
if(count[i-1]==1 &&
count[i-2]==1 && count[i-3]==1){
System.out.println("Output:Straight("+(i-2)+")");
}
else{
System.out.println("Output:High Card("+(i+1)+")");
}
break;
}
}
}
}
}
****Comment me in the Comment box for any Queries*****
Write a Java program that reads 5 integers, each of which is in the range of...
A standard poker deck of 52 cards has four suits, (symbols C, H, S, and D) and thirteen ranks (symbols A, 2, 3, 4, 5, 6, 7, 8, 9, T, J, Q, and K). Every card in the deck has both a value and a suit.1 A poker hand is any set of 5 cards from the standard poker deck. There are some special hands in poker, and these have ranks (i.e. some are better, some are worse). From best...
1. In a standard five-card draw poker, each player receives 5 cards from a standard deck of 52 cards. Some possible hands in this game are su d in Table 1 below1 (a) Create a sample space to describe all possible hands Bill can play with Let E be the event that the hand contains at least two cards of the same rank and F be the event that the hand contains at least three cards of the same rank...
Learning objectives 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. 5. To write functions Representing playing cards and hands of cards An individual playing card is represented as a string of two characters: • the first character is from "23456789TJQKA" and represents the rank, i.e., the number or value of the card. (Note that 10 is encoded...
I need to write a vb program for a poker game that uses a two-dimensional array... Here is the problem: A poker hand can be stored in a two-dimensional array. The statement Dim hand(3, 12) As Integer declares an array with 52 elements, where the first subscript ranges over the four suits and the second subscript ranges over the thirteen denominations. A poker hand is specified by placing 1%u2019s in the elements corresponding to the cards in the hand. Write...
Write a Java program that deals a five-card poker hand and then determines which of the following hands are contained in it: high card, pairs, two pair, three of a kind, flush. Test only for those hands. Use the numbers from 0 to 51 to represent the cards of the poker deck. 1. To deal the cards, your main method should call a secondary method that selects a random card. The secondary method should accept 5 integers that represent the...
Consider a regular deck of cards with 52 cards in total. (1) How many ways can we have a poker hand of 5 cards? (2) Four of a kind is a poker hand that contains all four cards of one rank and any other (unmatched) card. For example, 94 949 9♡ JA is a "four of a kind”. How many ways can we have "four of a kind" ? (3) In a poker hand of 5 cards, what's the probability...
Need help writing this program! Thanks in advance. Project4 Specifications: Determine Poker Hand A poker hand can be stored in a two-dimensional array. The statement: Dim aryintCards(4,14) as Integer (See AryCardExample.xlsx excel spreadsheet) declares an array which the first subscript 1-4 are the four suits and the second subscript ranges over the card denominations: 1-14: Ace, 2, ..., 10, Jack, Queen, King, Ace (repeated). First subscript of 0 is Total of each denomination. Second subscript of 0 is Total of...
1. Find the probabilities of Poker hands not covered in class. Recall in a Poker game, 5 cards are drawn uniformly at random from a deck of 52 cards. Each deck has 13 denominations ({A, 2, 3, . . . , 10, J Q, K)) and 4 suits (4,◇,0,6 ). In what follows consecutive denominations are But (J,Q,K, A, 21 is not considered consecutive. Find the probabilities of a. Straight Flush (5 cards of consecutive denomination, all of the same...
This activity needs to be completed in the Python language. This program will simulate part of the game of Poker. This is a common gambling game comparing five-card hands against each other with the value of a hand related to its probability of occurring. This program will simply be evaluating and comparing hands, and will not worry about the details of dealing and betting. Here follow the interesting combinations of cards, organized from most common to least common: Pair --...
Python Programming: An individual playing card is represented as a string of two characters: • the first character is from "23456789TJQKA" and represents the rank, i.e., the number or value of the card. (Note that 10 is encoded as letter T to make all card ranks to be single letters) • the second character is from "cdhs" and represents the suit (clubs, diamonds, hearts and spades respectively). For example, "Jd" would be the jack of diamonds, and "4s" would be...