Search:

Type: Posts; User: madjavapuppy

Search: Search took 0.10 seconds.

  1. Re: java.lang.ArrayIndexOutOfBoundsException help

    Ok made the changes, made an 'int count = 10;' for loop changed to 'for (int i=0; i<count; i++)' tried 11, but it caused an error after pay number is entered the test you showed came with...
  2. Re: java.lang.ArrayIndexOutOfBoundsException help

    Im not sure if its working now actually, what i put in says its an invalid pay number, but lets me put the rest of the details in and says it a success, then asks if I want to put another one in,...
  3. Re: java.lang.ArrayIndexOutOfBoundsException help

    wow thank you so much that seems to have worked i replaced it with:



    public static int findPayNum(int payNumber)
    {
    if (numStaff == 0)
    {
    System.out.println("\n\tError: No staff...
  4. Re: java.lang.ArrayIndexOutOfBoundsException help

    That's true, so how would i use the for loop in this situation?

    looking at it guessed it would start with 'for (int i=payNumber; i<count-1; i++);' is that right?
  5. Re: java.lang.ArrayIndexOutOfBoundsException help

    i don't how im going to use a for loop in this, is there no way to make it work with a do{} while?
  6. Re: java.lang.ArrayIndexOutOfBoundsException help

    Sorry obviously i don't understand the questions, 'findPayNumber' is used to keep track of the number of pay numbers and to find a pay number added in the method initaliseArrays:



    public...
  7. Re: java.lang.ArrayIndexOutOfBoundsException help

    public static int findPayNum(int payNumber)
    {
    if (numStaff == 0)
    {
    System.out.println("\n\tError: No staff members!");
    return -1;
    }
    boolean found = false;
    int count = 0;...
  8. Re: java.lang.ArrayIndexOutOfBoundsException help

    Well the value of count is equal to the number of pay numbers 'payNumber' and is changed when the user adds or removes a staff member, so no it shouldn't be 10 it should be 7 at first.
  9. Re: java.lang.ArrayIndexOutOfBoundsException help

    so would i do something like an if statement like

    if(count == 10)
    count -1;

    would that stop it?
  10. Re: java.lang.ArrayIndexOutOfBoundsException help

    Oh... well i tried it that way and it came up as



    Exception in thread "main" payNum.length=10, count=0
    payNum.length=10, count=1
    payNum.length=10, count=2
    payNum.length=10, count=3...
  11. Re: java.lang.ArrayIndexOutOfBoundsException help

    Ok this is what I got after doing it i used 'System.out.println(payNum.length + count);' which i hope was right.



    10
    11
    12
    13
    14
    15
  12. Re: java.lang.ArrayIndexOutOfBoundsException help

    Many thanks for telling me how to format, I think I understand what your saying 'MAX_STAFF' is set to 10 and the 3 errors I have which are at



    Exception in thread "main"...
  13. java.lang.ArrayIndexOutOfBoundsException help

    Hi im fairly new to Java and im trying out this program that would be used for managing staff members.

    However I have problems with options after you enter number while no errors come up it...
Results 1 to 13 of 14