Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help with java: ** Programmer defined objects can NOT be used for this project. Use of additional methods IS allowed but global variables declared

Need help with java:

** Programmer defined objects 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 USE PACKAGES. **

//Do this once at the top of the file

import java.util.*;

//Do this once at the beginning of main

Random r = new Random();

//Do this every time you want to draw a card

int val = r.nextInt(n);

In this project, you will write a program that deals five random playing cards. Each card will have a suit (Spades, Clubs, Hearts, or Diamonds) and a value (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. In this program, you will need to generate random numbers to simulate drawing cards.

Assume several card decks are being used. As shown in the last run above, its OK if you deal the same card multiple times (however, if your random numbers are working properly, it shouldnt 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, Queen, King, or Ace, where 11=Jack, 12=Queen, etc.).

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!).

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

Learn To Program Databases With Visual Basic 6

Authors: John Smiley

1st Edition

1902745035, 978-1902745039

More Books

Students also viewed these Databases questions

Question

b. Why were these values considered important?

Answered: 1 week ago