I'm making code for a Blackjack game.
I've already made the necessary switch statements to generate a random card and have set a variable to them so I don't have to keep copying and pasting.
My problem is that whenever I press run, it shows a zero and then the generated card. I know this is because I've set playerCard1 to zero, but I dunno how to get rid of it.
Here's my code if it's any help
public class var {
public static void main(String[] args) {
int playerCard1 = 0;
int suit = 0;
char suitChar = ' ';
int num = playerCard1;
//making playerCard1 generate a random number between 1 and 13
playerCard1 = (int)(Math.random() * 13 + 1);
//making suit generate a random number between 1 and 4 for first card
suit = (int)(Math.random() * 4 + 1);
System.out.println(num);
//switch statements for suit of player's first card
switch (suit){
case 1: suitChar = 'D'; //diamonds
break;
case 2: suitChar = 'S'; //spades
break;
case 3: suitChar = 'H'; //hearts
break;
case 4: suitChar = 'C'; //clubs
break;
}//end of switch statements for suit of player's first card
switch (playerCard1){
case 1: System.out.print("A" + suitChar);
break;
case 2: System.out.print("2" + suitChar );
break;
case 3: System.out.print("3" + suitChar);
break;
case 4: System.out.print("4" + suitChar );
break;
case 5: System.out.print("5" + suitChar );
break;
case 6: System.out.print("6" + suitChar );
break;
case 7: System.out.print("7" + suitChar);
break;
case 8: System.out.print("8" + suitChar );
break;
case 9: System.out.print("9" + suitChar);
break;
case 10: System.out.print("10" + suitChar );
break;
case 11: System.out.print("J" + suitChar );
break;
case 12: System.out.print("Q" + suitChar);
break;
case 13: System.out.print("K" + suitChar);
break;
}//end of switch statements for playerCard1
}//end of main
}//end of class