How to make a pattern by accepting a word?
import
java.io.*;
class
PatternWord
{
public
static
void
main(String args[])
throws
IOException
{
BufferedReader br =
new
BufferedReader(
new
InputStreamReader(System.in));
System.out.print(
"Enter any word : "
);
String s = br.readLine();
int
len = s.length();
for
(
int
i=
0
; i<len; i++)
{
for
(
int
j=
0
; j<=i; j++)
{
System.out.print(s.charAt(j));
}
System.out.println();
}
}
}
No comments:
Post a Comment