Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a JAVA program that simulates a deck of cards. There are 52 cards in a deck. A deck consists of four suits (Diamonds, Hearts,

Write a "JAVA" program that simulates a deck of cards. There are 52 cards in a deck. A deck consists of four suits (Diamonds, Hearts, Clubs and Spades). Each suit contains 13 values(Ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, Jack, Queen and King). The user will indicate how many cards they wish to draw from a deck of cards. Your program will then draw that many cards and then display the suits and values of all the cards drawn. You can assume you are drawing with replacement, which means you put each card back into the deck after drawing it.

Create a method that accepts one integer parameter and has a String array (or String[]) return type. The method will randomly draw cards from a simulated deck and add them to a string array that is returned after cards are drawn.

Create a method that accepts one String array (or String[]) parameter and has a void return type. The method will perform the System.out.println() function on all elements of the string array.

The main method of the program will receive user input and call both methods.

User input will be the parameter for the method 1 call

The returned string array from method 1 will be the parameter for the method 2 call

You may choose to use either the console or the Java dialog boxes for data input and output.

If the number of cards to draw is zero or a negative, your program should report the error and exit the program: you can do this with System.exit(0)

*Do not use private boolean*

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

More Books

Students also viewed these Databases questions

Question

What was Michael Ovitzs career path at Disney? Why?

Answered: 1 week ago

Question

Briefly explain RG 206 Credit licensing - Competence and training

Answered: 1 week ago