Search:

Type: Posts; User: KevinWorkman

Search: Search took 0.14 seconds.

  1. Replies
    17
    Views
    4,601

    Re: Counting Words in a File with a Loop

    Why in the world would you do it this way, when there are functions available for reading files word by word? For example, what happens with your algorithm if there are two spaces in a row? Or...
  2. Replies
    17
    Views
    4,601

    Re: Counting Words in a File with a Loop

    Sorry, but how is it not working? Are you getting an Exception? If so, give us the exact stack trace, pointing out any line numbers so we don't have to count. Also, it'd be nice if you could trim...
  3. Replies
    17
    Views
    4,601

    Re: Counting Words in a File with a Loop

    Take a closer look at how you're doing lineNumberAgain. It's the same thing.

    Hint: how many times do you initialize lineNumberAgain? In other words, how many times do you have "int...
  4. Replies
    17
    Views
    4,601

    Re: Counting Words in a File with a Loop

    Right. That's almost the same thing though, so I don't know where you're having trouble.

    Hint: this line:


    lineNumberAgain++;

    is the same as doing this:
  5. Replies
    17
    Views
    4,601

    Re: Counting Words in a File with a Loop

    I'm not sure what your question is. What are you trying to do with lineNumberAgain? Isn't that similar to what you're trying to do with Total (which really should be total, by the way)?
  6. Replies
    17
    Views
    4,601

    Re: Counting Words in a File with a Loop

    Well, you know how to scan in a line. How would you count the characters of any other String?

    Or you could try changing the Scanner delimiter to read in every individual char. The API is your...
  7. Replies
    17
    Views
    4,601

    Re: Counting Words in a File with a Loop

    So either re-initialize your Scanner before each method or store the data in some kind of data structure that you can go back to without reading from the file again.

    And for counting the...
Results 1 to 7 of 7