String roulette = keyboard.next();
if (roulette.length()!=14)
{
System.out.print("Error: 14 digits only");
System.exit(1);
}
I did this to make sure I have a length of 14. But my program also requires it to be numbers ONLY. It also needs to be a string. I don't want to parse int, I want my program to System.exit(1) if a letter is entered. Is there any way to do this?
I looked here https://docs.oracle.com/javase/8/docs/api/java/util/Scanner.html and https://docs.oracle.com/javase/8/docs/api/java/lang/Integer.html but cant find what im looking for
isDigitmethod that tells you if a character is a number. It's pretty easy to create your own version of that function though. That would actually be a good exercise for you. Anyways, just use that method to check if every character is a digit.