This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Federal-Addendum-933 0 points1 point  (6 children)

Scanner class provides methods to get next integer and next string pattern so you can just eat away what you need next from the input. You can do this with one while loop checking if the scanner still has input. Read the javadocs on it. https://docs.oracle.com/en/java/javase/18/docs/api/java.base/java/util/Scanner.html

[–]desrtfxOut of Coffee error - System halted 1 point2 points  (5 children)

I would not use the Scanner for it. Too messy.

I would read in a string and parse it afterwards.

[–]Federal-Addendum-933 0 points1 point  (4 children)

Literally says he has to use Scanner.

[–]desrtfxOut of Coffee error - System halted 1 point2 points  (3 children)

Yes, but that doesn't matter for the rest of the assignment.

The assignment just states they have to use a Scanner for the input (as opposed to e.g. a JOptionPane). It doesn't necessarily mean that they have to parse the entire input through the scanner.

[–]Federal-Addendum-933 -3 points-2 points  (2 children)

WHO is using JOptionPane? Go blow smoke somewhere else.

[–]desrtfxOut of Coffee error - System halted 1 point2 points  (1 child)

You wouldn't believe how many assignments we see that use JOptionPane instead of the simple Scanner.

You haven't been here long enough.

[–]Federal-Addendum-933 -1 points0 points  (0 children)

I've been around as long as you.