Designing Patterns - Print 'Z'.
SOURCE CODE
import java.io.*;
import java.util.*;
public class Z
{
public static void main(String args[])
{
Scanner sc=new Scanner (System.in);
System.out.print("Enter a odd number >=5 :");
int n=sc.nextInt();
int a=n/2+1;
System.out.println("\n");
if(n>=5&& n%2!=0 )
{
for(int i=1;i<=n;i++)
{
for(int j=n;j>0;j--)
{
if(i==1||i==n||j==i)
System.out.print("Z ");
else
System.out.print(" ");
}
System.out.println();
}
}
else
System.out.println("Invalid Input.");
}
}
import java.util.*;
public class Z
{
public static void main(String args[])
{
Scanner sc=new Scanner (System.in);
System.out.print("Enter a odd number >=5 :");
int n=sc.nextInt();
int a=n/2+1;
System.out.println("\n");
if(n>=5&& n%2!=0 )
{
for(int i=1;i<=n;i++)
{
for(int j=n;j>0;j--)
{
if(i==1||i==n||j==i)
System.out.print("Z ");
else
System.out.print(" ");
}
System.out.println();
}
}
else
System.out.println("Invalid Input.");
}
}
OUTPUT
If you have any question then leave a comment below I will do my best to answer that question.
conshaeFjua Alex Friedrich https://marketplace.visualstudio.com/items?itemName=1pusresva-re.Xeno-Time-Inception-gratuita
ReplyDeletemukelasni