Hi all, i need to make a translater program that translate words. example if u type in hello all it should return ellohsese llasese. it moves the first letter in the words to last and puts sese at the end of the words, then i need to have a way to reverse the method, so if i type in ellohsese llasese it should return hello all.
i have got the program to almost work as i like , the thing is it just works if i type in one word ie hello and returns ellohsese. and i dont really know how to fix it, so if someone could give me some advise to how i can get it to work i would be happy
import javax.swing.*; public class TransLater { public static void main(String[] arg) { String val; JOptionPane.showMessageDialog(null, "Welcome to the Translater"); while(true) { val = JOptionPane.showInputDialog("1) Translate to \n2) Translate from"); if(val.equals("1")) { StringBuffer str = new StringBuffer(""); String indata; char first; indata = JOptionPane.showInputDialog("Type ur words here:"); str.insert(0,indata); first = str.charAt(0); str.deleteCharAt(0); str.append(first); str.append("sese"); JOptionPane.showMessageDialog(null, str); } else if(val.equals("2")) { String indata2; indata2 = JOptionPane.showInputDialog("Type ur words here:"); while (indata2.endsWith("sese")) { indata2 = indata2.substring(0, indata2.length() - 4); String last = indata2.substring(indata2.length() -1); indata2 = indata2.substring(0, indata2.length() -1); JOptionPane.showMessageDialog(null, last + indata2); } } else { JOptionPane.showMessageDialog(null, "Wrong selection, try again"); } } } }