Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that simulates a deck of cards using java. Use the scanner class. There are 52 cards in a deck. A deck consists

Write a program that simulates a deck of cards using java. Use the scanner class. 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.

Example Run

Assignment Requirements

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)

Perform the following test cases:

Cards to draw

Test run 1

10

Test runs 2, 3, 4

30 (perform 3 times)

Test run 5

0

Test run 6

-10

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_2

Step: 3

blur-text-image_3

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

Entity Alignment Concepts Recent Advances And Novel Approaches

Authors: Xiang Zhao ,Weixin Zeng ,Jiuyang Tang

1st Edition

9819942527, 978-9819942527

More Books

Students also viewed these Databases questions

Question

1. Which position would you take?

Answered: 1 week ago