Welcome to the CSC Q&A, where you can get help (and share your knowledge) about computer science!

Any one have any hints on Self-Check 6.11?

+4 votes
asked Feb 10, 2015 in (Winter 14) by Lauren Johnson (100 points)

1 Answer

+2 votes

(Sorry this response is a bit late... evidently your classmates aren't checking the Q&A frequently enough!)

This one is a bit tricky.  There are several issues, but the hardest one to fix is probably this:

To count the words in one line of text, you need to make a new Scanner that just reads that line. (See the stuff in section 6.3 on line-based processing).

So before the inner while loop, create a Scanner object that reads the line:

Scanner lineInput = new Scanner(line);

Then the inner while loop should start like this:

while (lineInput.hasNext()) {

    String word = lineInput.next();


Hope that helps... maybe another student will post a more complete answer here...

answered Feb 10, 2015 by Forrest Stonedahl (100 points)