Hello good day to all...
is there anyone can help or suggest me how my code work successfully.
Actually the code was working well, but i wanted to change it`s content to GUI form.
the program description was the user must input a word/String and shuffle/scramble the word that the user inputted and shows the possible output of the program to GUI form.
Collaborating with the LinkedList data structure...
import java.util.LinkedList;
import java.io.*;
import javax.swing.JOptionPane;
public class ScrambleWord {
public static void main(String args[]) throws IOException{
LinkedList<String> scrambleWordList = new LinkedList<String>();
String str;
JOptionPane.showMessageDialog(null, "Welcome to the Program");
System.out.println("Enter a Word:");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
str=br.readLine();
System.out.println("Permutations are :");
permute("", str);
scrambleWordList.add(str);
System.out.println("\nThe First Word in the Scramble List is \t \b"+scrambleWordList.getFirst());
}
public static void permute(String beginningString, String endingString) {
if (endingString.length() <= 1)
System.out.println(beginningString + endingString);
else
for (int i = 0; i < endingString.length(); i++) {
try {
String newString = endingString.substring(0, i) + endingString.substring(i + 1);
permute(beginningString + endingString.charAt(i), newString);
} catch (StringIndexOutOfBoundsException exception) {
exception.printStackTrace();
}
}
}
}