Transcribed TextTranscribed Text

Exercise 8: Create an array that models a deck of cards. For example, “1_of_diamonds” represents the ace of diamonds, “2_of_diamonds” represents the 2 of diamonds, up to “13_of_diamonds”, which represents the King of diamonds. The suits clubs, hearts and spades are represented in a similar manner. All these elements should be in a single array. The array should be populated using a counter controlled loop. Output the contents of the array to the screen. Shuffle the deck. The deck can be shuffled using the method below. Note that you can pass your array as an argument to the method and that your program needs to import the java.util.Random object. Once the deck is shuffled, print out the contents of your shuffled deck to the screen. Name your program Exercise 9: Write a program,, which presents the user with menu options. The options presented in the menu link to the previous 8 exercises. For example, if the user selects option 1, then the program from exercise 1 is run. When exercise 1 is completed running, the option menu should be presented to the user again so they may choose another exercise to run. If the user selects an invlaid option, write a message to the screen indicating this.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

import java.util.Random;

public class Cards{

//private field storing cards
private String[] cards;
//names of the suits
final String[] suit_names = {"diamonds", "spades", "heart", "clubs"};
//number of suits
int suits = 4;
//how many cards we have per a suit
int cards_per_suit = 13;
//constructor of a class
public Cards(){
//create array with suits*cards_per_suit elements
cards = new String[suits*cards_per_suit];
//and populate it
for (int j = 0; j < suits; j++){
for (int i = 0; i < cards_per_suit; i++){
cards[j * cards_per_suit + i] = String.valueOf(i+1)+"_of_"+suit_names[j];

By purchasing this solution you'll be able to access the following files: and

for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats