Question: In Java.. Write a program that reads five integer values from the user, then analyzes them as if they were a hand of cards. When

In Java..

Write a program that reads five integer values from the user, then analyzes them as if they were a hand of cards. When your program runs 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: 7

Card 3: 8

Card 4: 2

Card 5: 9

Pair!

(This is a pair, since there are two eights).

Here is a table that shows the different possible types of hands, with an example of each. You are only required to find the hands Pair and Straight. Feel free to work on the others if you are interested.

Required Hands

Description

Example

High Card

If the hand is not a straight, and there are no matches then it is simply called a "high card" hand.

2, 5, 3, 8, 7

Pair (required)

Two of the cards are identical

2, 5, 3, 5, 7

Straight (required)

A sequence of values with no matches and no gaps. They do not need to be in order

3, 4, 7, 6, 5

Optional Hands

Description

Example

Two Pair

Two different pairs

2, 5, 3, 5, 3

Three of a kind

Three matching cards

5, 5, 3, 5, 7

Full House

A pair, and a three of a kind

5, 7, 5, 7, 7

Four of a kind

Four matching cards

2, 5, 5, 5, 5

(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 either "Straight", "Pair", or "High Card".

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!