41,891 views
21 votes
21 votes
Please help with this question in java.
Computers .​

Please help with this question in java. Computers .​-example-1
User Kemia
by
2.7k points

1 Answer

25 votes
25 votes

Here is the program~

/*Pattern.Java.*/

import java.util.*;

public class Pattern_Prog

{

public static void main (String args[ ])

{

Scanner input = new Scanner(System.in);

int length;

System.out.print("Enter a word : ");

String word = input.next( );

length = word. length( );

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

{

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

{

System.out.print(" ");

}

System.out.println(word.substring(0,length-i));

}

input.close( );

}

}

Hope it helps you!!