Trying to teach myself Java, for better or for worse. The program I intend to create should pick a random playing card from a deck of cards, determine the suit and face value, then return all variables as shown: "You picked 14, the 2 of Hearts."
The problem is I can not use the strings I created during the if/else-if statements in my final print statement:
package playing_card_game;
import java.util.*; // Needed for a Random Number Generator
public class Cards {
]
public static void main(String[] args) {
Random rand = new Random();
int cardNumber = rand.nextInt(52);
int suitName = cardNumber/13;
if (suitName == 0){
String s = "Spades";}
else if (suitName == 1){
String s = "Hearts";}
else if (suitName == 2){
String s = "Clubs";}
else if (suitName == 3);{
String s = "Diamonds";}
int faceValue = suitName%13;
if (faceValue == 0){
String f = "Ace.";}
else if (faceValue == 1){
String f = "2.";;}
else if (faceValue == 2){
String f = "3.";}
else if (faceValue == 3){
String f = "4.";}
else if (faceValue == 4){
String f = "5";}
else if (faceValue == 5){
String f = "6.";}
else if (faceValue == 6){
String f = "7.";}
else if (faceValue == 7){
String f = "8.";}
else if (faceValue == 8){
String f = "9.";}
else if (faceValue == 9){
String f = "10.";}
else if (faceValue == 10){
String f = "11.";}
else if (faceValue == 11){
String f = "12.";}
else if (faceValue == 12);{
String f = "13.";}
System.out.println("You picked " + cardNumber + ", the " + f + " of " + s + ".");
}
}