Re: Java Help for a Beginner



On Oct 22, 6:27 pm, markspace <nos...@xxxxxxxxxxx> wrote:
Normally, I'd say "do your own homework."  It's important to ask your
instructor or TA so they know where you are having trouble.  However,
this may be a subtle error.

Booter wrote:
           //set delimiter to a ","
           delimiter.useDelimiter(",");

You might try ",\\s*" instead.  Normally there's white space in a file
like this, and I'm not really sure what the response of the scanner will
be if it tries to convert an int with white space.  Note that white
space includes newlines, so I don't see how this will progress to a new
line as you have it now.  If you have white space before the comma,
you'll need something like "\\s*,\\s*".

I could be all wrong, and I didn't test it, but it's something to look at..

So I tested it with the the following input:

1,2,3,-1

When it goes through the while loop it works until I get to the part
where

grade = delimiter.nextInt();

tries to get the -1. Once it reaches that line it just stalls and
doesn't progress any further.
.