Search:

Type: Posts; User: pbrockway2

Search: Search took 0.08 seconds.

  1. Replies
    28
    Views
    3,070

    [SOLVED] Re: Cant find stupid bug.

    What is your code now? Did you remove 0-9 in both places?
  2. Replies
    28
    Views
    3,070

    [SOLVED] Re: Cant find stupid bug.

    Yes. After a little arithmetic and



    //Scanner in = new Scanner(new File ("Sub.txt"));
    Scanner in = new Scanner(new StringReader("aaa1 1asd 1 abc 1"));


    I see the same thing.
  3. Replies
    28
    Views
    3,070

    [SOLVED] Re: Cant find stupid bug.

    Which is line 53? Remember that you calculate the array position with something like c-'a' which could end up with a bad value like -48 depending on the value of c. To debug use...
  4. Replies
    28
    Views
    3,070

    [SOLVED] Re: Cant find stupid bug.

    Yes, exactly.
  5. Replies
    28
    Views
    3,070

    [SOLVED] Re: Cant find stupid bug.

    OK - so you have to debug.

    First - not actually needed here, but a good idea anyway - use the trick I suggested earlier of replacing the scanner with one that merely reads a short string. The...
  6. Replies
    28
    Views
    3,070

    [SOLVED] Re: Cant find stupid bug.

    for (int i = 0; i < 26; i++)
    {
    System.out.print(" " + obj.getAlph()[i]);
    System.out.printf("%11s", obj.getOccurance(obj.getFile())[i]); //<-------
    System.out.printf("%19s%n",...
  7. Replies
    28
    Views
    3,070

    [SOLVED] Re: Cant find stupid bug.

    public int[] getOccurance(String file)
    {
    for (int i = 0; i < lets; i ++)
    {
    char c = getFile().charAt(i);
    occurance[c - 'a']++;
    }
    return occurance;
    }
  8. Replies
    28
    Views
    3,070

    [SOLVED] Re: Cant find stupid bug.

    You're welcome.
  9. Replies
    28
    Views
    3,070

    [SOLVED] Re: Cant find stupid bug.

    Well, it "works" OK. Computer code always does, so long as it compiles. It's when its working doesn't conform to our intentions that we have a problem...

    In this case file=file.substring(1) will...
  10. Replies
    28
    Views
    3,070

    [SOLVED] Re: Cant find stupid bug.

    First of all you still scan the stream in two places. In particular you read it again in countLetters(), and I predict this will not be good:



    import java.io.IOException;
    import...
  11. Replies
    28
    Views
    3,070

    [SOLVED] Re: Cant find stupid bug.

    It turns out that countLetters() is extremely relevant if you take into account that this method alters where in the input stream your scanner is pointing. System.out.println() can be used to...
  12. Replies
    28
    Views
    3,070

    [SOLVED] Re: Cant find stupid bug.

    double post removed
  13. Replies
    28
    Views
    3,070

    [SOLVED] Re: Cant find stupid bug.

    Could you please edit your post so that it's readable: put
    at the start of a section of code and at the end.

    -----

    Think about (and maybe document in the code!) what the public methods of...
Results 1 to 13 of 13