You are on page 1of 1

PROGRAM 25 – To create a pattern from entered string

Program :

import java.io.*;

class pattern
{
public static void main (String args[]) throws IOException
{
int i,sp,j,k,l;
BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));
System.out.println("enter the string =");
String s = br.readLine();
l=s.length();
for(i=0;i<l;i++)
if(i==l/2)
System.out.println(s);
else
{
sp=Math.abs((l/2)-i);
for(j=sp;j<l/2;j++)
System.out.print(" ");
k=0;
while(k<3)
{
System.out.print(s.charAt(i));
for(j=0;j<sp-1;j++)
System.out.print(" ");
k++;
}
System.out.println(" ");
}
}
}

You might also like