Welcome to the Ranch
Please start by explaining what sort of input you require. It is very easy to use the methods of a Scanner to verify that its next token will match an
int for example, which will return
false before line 2 and
true before line 3. It is much harder to verify that the next token has a particular text format;
hasNext() only shows that you have not yet reached the end of the input. Which means, by the way, that a Scanner reading from System.in should always return
true from
hasNext().
You can try reading the next token and using its matches/match() method with a regular expression (=regex), or something similar, but that depends on knowing what your specification for the required input is. Beware: regexes need special care because they can be difficult to set up correctly.
Don't create multiple Scanners to read from System.in. Use a utility class that does all your keyboard input; you can set up the methods with a loop, like that shown
here which will reject input in the incorrect format. As I said above, that would require special upgrading for
next() to return something matching a particular regex.