I am brand new to java this semester. So far it has been going well, but having trouble figuring out how to do this one part of a program I am working on. This program requires the user to input a playing card, abbreviated, such as 9D for 9 of Diamonds, AC for Ace of Clubs and so on. It reads a 2-3 character string from the user, and then using if statements outputs the value and suit of the playing card. For instance, the user inputs "JS", the program should output "Jack of Spades" and terminate. The if statements are not the issue I am having, but my instructor wants us to have it input as a string, then break apart the string input by the user, and use those pieces as conditions for the if statements. The problem I am coming into is how to break apart the string when the first part of the string can be either numbers or characters. Here is a snippet of the program I have written so far.
I am just stuck on how to break apart the string basically.
NOTE: DO NOT SEEK ANSWER GIVEN TO ME, JUST IDEA OF WHAT I SHOULD BE THINKING ABOUT TO GET TO THE CORRECT CODE!
import java.util.*;
public class CardConverter
{
public static void main(String[] args)
{
//Declare variables and set up input for user.
Scanner keyboard = new Scanner(System.in);
String input;
int valueNumber;
char valueChar;
char suit;
//Get input from the user using nextLine command.
System.out.println("Input the abbreviated card, first the number or face value, then the suit: ");
input = keyboard.nextLine();
valueNumber = keyboard.nextInt();
}
}
Thanks in advance.