Hi to all!!!! I Am Arpit Vijay Vergiya.
On this Blog i tried to share about Java.
I hope this blog will help you to learn many new things in java.
Keep visiting!!!
Keep sharing

by

Swastik pattern using java




import java.util.Scanner;
class Swastik{
		
		public static void main(String args[])
		{
				Scanner sc = new Scanner(System.in);
				System.out.println("Enter number");
				int num = sc.nextInt();
				for(int i=1;i<=num;i++)
				{
						for(int j=1;j<=num;j++)
						{
								if((j==1 && i<=num/2) || (j==num/2) || (i==num/2)||(i==1 && j>=num/2) || ((i==num/2 || j==num) && i>num/2) || (i==num && j<=num/2))
								{
										System.out.print("*");
								}
								else
									System.out.print(" ");
						}
						System.out.println();
				}
		}
}




0 comments:

Post a Comment