Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The problem desciption is the blue text, I have included what I have so far, I\'

ID: 3731222 • Letter: T

Question

The problem desciption is the blue text, I have included what I have so far, I'm very confused on how to search the 2d array diaganoly.

*Given a 2D array of characters, return true if any row, column or diagonal of *the table has only lower-case letters. You can assume the bingo table is a square. *@param table se) ereturn true if any row, column, or diagonal lower-case letter bingo is found. false otherwise. public static boolean caseBingo(char [] table) { boolean result = false; for (int i = 0; i

Explanation / Answer

public static boolean caseBingo(char[][] table)

{

    int i, j;

   

    // traverse the row

    for( i = 0 ; i < table.length ; i++ )

    {

        boolean flag = true;

       

        // traverse the columns

        for( j = 0 ; j < table[i].length ; j++ )

        {

            if( table[i][j] < 97 && table[i][j] > 122 )

            {

                flag = false;

                break;

            }

        }

       

        if( flag == true )

            return true;

    }

   

    // traverse the columns

    for( i = 0 ; i < table[0].length ; i++ )

    {

        boolean flag = true;

       

        // traverse the row

        for( j = 0 ; j < table.length ; j++ )

        {

            if( table[j][i] < 97 && table[j][i] > 122 )

            {

                flag = false;

                break;

            }

        }

       

        if( flag == true )

            return true;

    }

   

    boolean flag = true;

   

    // traverse the diagonal

    for( i = 0 ; i < table.length ; i++ )

    {

        if( table[i][i] < 97 && table[i][i] > 122 )

        {

            flag = false;

            break;

        }

    }

   

    if( flag == true )

        return true;

   

    flag = true;

   

    // traverse the diagonal

    for( i = table.length ; i >= 0 ; i-- )

    {

        if( table[i][i] < 97 && table[i][i] > 122 )

        {

            flag = false;

            break;

        }

    }

   

    if( flag == true )

        return true;

   

    return false;

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote