I need to write a program that determines whether a string inputted by the user is a word (all letters), a number (all digits), "something else" (starts with digit, ends with number, or vice versa), or an empty string. This is what I have so far:
import java.util.Scanner;
public class Lab3Part1 {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter a string: ");
keyboard.nextLine();
String userInput = keyboard.nextLine();
char c1 = userInput.charAt(userInput.length());
char c2 = userInput.charAt(userInput.length()-1);
Character.isDigit(c1);
Character.isDigit(c2);
if (userInput = )
{
System.out.println("\"" + userInput + "\" is a word");
}
else if (userInput = )
{
System.out.println("\"" + userInput + "\" is a number");
}
}
}
Where do I go from here? I don't know how to code for determining if a string is a word, number, something else, or empty. Please help! Thank you.