Showing posts with label pattern designs. Show all posts
Showing posts with label pattern designs. Show all posts

Java program for the pattern of 'E' | Patterns in JAVA | JAVA POINT

 

Java program for E



Ques : Write a java program for following Pattern of  'E' :


     * * * * 

            *                 

     *         

     * * * * 

     *         

             *                 

     * * * * 


PROGRAM :


import java.util.Scanner;

public class PatternE

{

    public static void main(String[] args)

    {

        System.out.print("Enter the number of      

        rows : ");.                // 7

        Scanner scan=new Scanner(System.in);

        int n=scan.nextInt();

        System.out.println();

        for (int i=0;i<n ;i++ )

        {

            for (int j=0;j<=n/2 ;j++ )

            {

                if (i==0 || i==n-1 || i==n/2 || j==0)

                {

                    System.out.print("* ");

                }

                else

                {

                    System.out.print("  ");

                }

            }

            System.out.println();

        }

    }

}