DEV Community

Neelakandan R
Neelakandan R

Posted on

pattern using forLOOP--**U,T,O,N,Z,X,E,F,H,K,M,Y,W,P,Q,R.**

U,T,O,N,Z,X,E,F,H,K,M,Y,W,P,Q,R.

package Afterfeb4;

public class forlooppattern1 {

    public static void main(String[] args) {
        // findstar();
        // findU();
        // findT();
        // finfO();
        // findN();
        // findZ();
        // findX();
        // findparttenE();
        // findparttenF();
        // findparttenH();
        // findparttenK();
        // findpartternM();
        // findpartternY();
        // findpartternW();
        // findpartterP();
        // findpartternQ();
        findpartternR();

    }

    private static void findpartternR() {
        for (int row = 1; row <= 9; row++) {
            for (int col = 1; col <= 9; col++) {
                if (col == 1 || row == 1 && col <= 5 || col == 5 && row <= 5 || row == 5 && col <= 5 || row - col == 5)

                    System.out.print("* ");

                else
                    System.out.print("  ");

            }
            System.out.println();
        }

    }

    private static void findpartternQ() {
        for (int row = 1; row <= 9; row++) // ---
        {
            for (int col = 1; col <= 9; col++)// ||
            {
                if (col == 1 && row <= 7 || col == 7 && row <= 7 || row == 1 && col <= 7 || row == 7 && col <= 7
                        || col == row && row > 3)

                    System.out.print("* ");

                else
                    System.out.print("  ");

            }
            System.out.println();
        }

    }

    private static void findpartterP() {
        for (int row = 1; row <= 9; row++) {
            for (int col = 1; col <= 9; col++) {
                if (col == 1 || row == 1 || col == 9 && (row <= 5) || row == 5)

                    System.out.print("* ");

                else
                    System.out.print("  ");

            }
            System.out.println();
        }

    }

    private static void findpartternW() {
        for (int row = 1; row <= 9; row++) {
            for (int col = 1; col <= 9; col++) {
                if (col == 1 || col == 9 || col + row == 10 && (row >= 5) || col == row && (row >= 5))

                    System.out.print("* ");

                else
                    System.out.print("  ");

            }
            System.out.println();
        }

    }

    private static void findpartternY() {

        for (int row = 1; row <= 9; row++) {
            for (int col = 1; col <= 9; col++) {
                if (col + row == 10 && (row <= 5) || col == row && (row <= 5) || col == 5 && (row >= 5))

                    System.out.print("* ");

                else
                    System.out.print("  ");

            }
            System.out.println();
        }

    }

    private static void findpartternM() {
        for (int row = 1; row <= 9; row++) {
            for (int col = 1; col <= 9; col++) {
                if (col == 1 || col == 9 || col + row == 10 && (row <= 5) || col == row && (row <= 5))

                    System.out.print("* ");

                else
                    System.out.print("  ");

            }
            System.out.println();
        }

    }

    private static void findparttenK() {
        for (int row = 1; row <= 9; row++) {
            for (int col = 1; col <= 9; col++) {
                if (row + col == 4 || row - col == 2 || col == 1)
                    System.out.print("* ");
                else
                    System.out.print("  ");
            }
            System.out.println();
        }

    }

    private static void findparttenH() {
        for (int row = 1; row <= 9; row++) {
            for (int col = 1; col <= 9; col++) {
                if (row == 5 || col == 9 || col == 1)
                    System.out.print("* ");
                else
                    System.out.print("  ");
            }
            System.out.println();
        }

    }

    private static void findparttenF() {
        for (int row = 1; row <= 9; row++) {
            for (int col = 1; col <= 9; col++) {
                if (row == 1 || row == 5 || col == 1)
                    System.out.print("* ");
                else
                    System.out.print("  ");
            }
            System.out.println();
        }

    }

    private static void findparttenE() {
        for (int row = 1; row <= 9; row++) {
            for (int col = 1; col <= 9; col++) {
                if (row == 1 || row == 5 || row == 9 || col == 1)
                    System.out.print("* ");
                else
                    System.out.print("  ");
            }
            System.out.println();
        }

    }

    private static void findX() {
        for (int row = 1; row <= 9; row++) {
            for (int col = 1; col <= 9; col++) {
                if (col + row == 10 || col == row)
                    System.out.print("* ");
                else
                    System.out.print("  ");
            }
            System.out.println();
        }

    }

    private static void findZ() {
        for (int row = 1; row <= 9; row++) {
            for (int col = 1; col <= 9; col++) {
                if (row + col == 10 || row == 1 || row == 9)
                    System.out.print("* ");
                else
                    System.out.print("  ");
            }
            System.out.println();
        }

    }

    private static void findN() {
        for (int row = 1; row <= 9; row++) {
            for (int col = 1; col <= 9; col++) {
                if (row == col || col == 1 || col == 9)
                    System.out.print("* ");
                else
                    System.out.print("  ");
            }
            System.out.println();
        }

    }

    private static void finfO() {
        for (int row = 1; row <= 9; row++) {
            for (int col = 1; col <= 9; col++) {
                if (row == 1 || row == 9 || col == 1 || col == 9)
                    System.out.print("* ");

                else
                    System.out.print("  ");

            }
            System.out.println();
        }

    }

    private static void findT() {
        for (int row = 1; row <= 9; row++) {
            for (int col = 1; col <= 9; col++) {
                if (row == 1 || col == 5)
                    System.out.print("* ");
                else {
                    System.out.print("  ");

                }
            }
            System.out.println();
        }
    }

    private static void findU() {

        for (int row = 1; row <= 9; row++)// ---
        {
            for (int col = 1; col <= 9; col++) {
                if (col == 1 || col == 9 || row == 9)// || col
                    System.out.print("* ");
                else
                    System.out.print("  ");
            }
            System.out.println();
        }

    }

    private static void findstar() {
        for (int row = 1; row <= 9; row++) {
            for (int col = 1; col <= 9; col++) {
                System.out.print("* ");
            }
            System.out.println("  ");
        }

    }

}

Enter fullscreen mode Exit fullscreen mode

Top comments (0)