Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java help Also: Determine not only if the hand contains a pair but if it contains four of a kind, three of a kind or

Java help
image text in transcribed
Also:
Determine not only if the hand contains a pair but if it contains four of a kind, three of a kind or two pairs. Display the BEST (highest) classification for your poker hand (four of a kind, three of a kind, two pair, one pair or no pair), along with the high card. In the rare case you draw a full house (3 of a kind and one pair), you can just display 3 of a kind (but also OK to display Full House instead
In this project, you will write a program that "deals" five random playing cards. Fach card will have a sait (Spades, Clubs, Hearts, or Diamonds) and a yolue (2-10, Jack, Queen, King, or Ace). You will then display the five cards, then display whether there is a pair (two cards with the same value) as well as the highest card (with Ace being high). Again, you are just determining if any pairs exist and the highest card. Here are four sample runs of the program from the command line (Console 1/0 ): *"Notice in the last run that the 5 of Diamonds was drann nvice. This is OK for this profect. In this program, you will need to generate random numbers to simulate "drawing" cards, Generating a random number was covered in lecture and in lab during Weck 2 and in your zyBook (Section 3.1). IV Do this once at the top of the file import java.util."; HDo this once at the beginning of main Random r= new Random( ) : IDo this every time yeu want to draw a card intval=r.nextlut(n);(willgeneratenandomnamberfromuptobutnotincluden) Requirements / Tips: As with Project 1. Progenamuer defined abiects can NOT be used for this project. Use of additional methods IS allowed but global variables declared outside of any method are NOT allowed. You must properly pass values between methods. Also, do NOT USF. PACKAGES in this course. Packages cause compiling /execution errors for GTAs when grading and they are not necessary for the projects assigned in this course. - To simplify grading, the output of your program must look. EXACTLY like the sample run shown. This includes spacing, line feeds, spelling, capitalization, etc. - Assume several card decks are being used. As shown in the last run above, it's OK if you deal the same card multiple times (however, if your random numbers are working properly, it shoulda't happen often). - If the hand has multiple pairs, you only need to display one of them. - If there are no pairs, display "You have no pairs". - I might suggest generating a random number from 0 - 3 or 1.4 and use those values to represent the 4 suits (Spades, Clubs, Hearts, or Diamonds) and a random number from 2-14 to represent the card value (2-10, Jack, Qheen, King. or Ace, where 11= Jack. 12 -Queen, etc.)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems An Application Oriented Approach Complete Version

Authors: Michael Kifer, Arthur Bernstein, Richard Lewis

2nd Edition

0321268458, 978-0321268457

More Books

Students also viewed these Databases questions

Question

Solve using any method. (log 3 x) 2 - log 3 x 2 = 3

Answered: 1 week ago