[Solved] Unable to get the right output for average number


When you do

Board o= new Board();

inside getRow, you are making a new board with (presumably) row at zero. It is not the same board that you construct in main and set row to 10.

To pass board from main into getRow, add it as an argument:

private static int getRow(Scanner c, Board o) {
    int b=-1;
    while(b<0 || b>o.getRow()/2) {
        System.out.println("Please enter correct row");
        b=c.nextInt();
    }
    return b;
}

and pass it in when you call getRow from main:

col = getRow(src, b);

solved Unable to get the right output for average number