Create a class called CardDeck with a main method contents exactly as shown here:
{
String[] deck=new String[52];
createDeck(deck);
for(int i=0; i<52; i++)
System.out.println(deck[i]);
}
You should create a method called createDeck which populates the array you created in the main method. You must use four loops, each creates the 13 cards for one of the four suits. Within the loop the card names should be automatically generated and inserted in the array. (e.g., “Ace of Spades”, “2 of Spades”…”King of Hearts”, etc.) You must use loops to generate the card names, you must not create 52 literal Strings.
public class CardDeck
{
public static void main(String[] args)
{
String[] deck=new String[52];
createDeck(deck);
for(int i=0; i<52; i++)
System.out.println(deck[i]);
}
public static void createDeck(String[] myDeck)
{
String[] num={"Ace","2","3","4","5","6","7","8","9","10","Jack","Queen","King"};
int count=0;
for(int x=0; x<13; x++)
myDeck[x]=num[x]+" of Diamonds";
count++;
for(int x=13; x<26; x++)
myDeck[count]=num[count]+" of Spades";
count++;
for(int x=26; x<39; x++)
myDeck[count]=num[count]+" of Hearts";
count++;
for(int x=39; x<52; x++)
myDeck[count]=num[count]+" of Clubs";
} // end createDeck
} // end class CardDeck
What is wrong with my code?