Search:

Type: Posts; User: bengregg

Search: Search took 0.09 seconds.

  1. Replies
    17
    Views
    4,593

    Re: Counting Words in a File with a Loop

    Lol I'm trying to seperate the program into classes now.
    The program works, it takes a file and counts the number of lines, words, and characters:




    import java.io.File;
    import...
  2. Replies
    17
    Views
    4,593

    Re: Counting Words in a File with a Loop

    But the program works none the less. Now I'm just working on separating the program into classes so it is object oriented.

    I have My getWords



    import java.util.Scanner;

    /**
    *
  3. Replies
    17
    Views
    4,593

    Re: Counting Words in a File with a Loop

    Lol nevermind silly mistake I got it...

    int lineNumberAgain = 1;

    int totalChars=0;
    while (three.hasNextLine())
    {
    String lineagain = three.nextLine();
    int lineChars = lineagain.length();...
  4. Replies
    17
    Views
    4,593

    Re: Counting Words in a File with a Loop

    I know but the problem I am gaving is with int totalChars = lineChars + totalChar; (used to be int Total = howLong + Total;
    ) because it says that totalChars is not initiated. When I initiate...
  5. Replies
    17
    Views
    4,593

    Re: Counting Words in a File with a Loop

    lineNumberAgain starts at the first line and for every loop it goes to the next line. The total is supposed to keep track of the total number of characters.
  6. Replies
    17
    Views
    4,593

    Re: Counting Words in a File with a Loop

    Lol, almost there.

    Here is what I have for the find Characters:



    File inputFileThree = new File(inputFileName);
    Scanner three = new Scanner(inputFileThree);
  7. Replies
    17
    Views
    4,593

    Re: Counting Words in a File with a Loop

    Hey thanks for the advice. For some reason I thought I couldn't change System in, I thought it needed to be together for whatever reason. So I got it so it can count the lines and words now. However,...
  8. Replies
    17
    Views
    4,593

    Counting Words in a File with a Loop

    So the point of the program is to input a file and have the program generate the number of lines, characters, and words. As of right not I can generate the lines and the words. However, I cannot...
Results 1 to 8 of 8