hi all!
i have searched on this forum and in all my java textbooks available to do this but in vain. all i found was how to do it in VB.net or C++ etc. which didn't help at all.
so can someone please kindly hint me here...
1. a user inputs a sentence
2. needs to be converted to capitals
3. i need to replace vowels with other consonants
4. reverse the sentence
i managed to do up till number 3 but couldn't do number 4!
Front end class:CODE
import javax.swing.*;
public class RunEn
{
public static void main(String[] args)
{
//var
String sent;
//in
sent = JOptionPane.showInputDialog(null,"Please input sentence: ");
//pro
En obj = new En(sent);
//out
JOptionPane.showMessageDialog(null,"Encrypted version: "+obj.getFinal());
}
}
Back end class:CODE
public class En
{
private String sent, caps, vows, vows1, vows2, vows3, vows4;
public En(String sentT)
{
sent = sentT;
caps = sent.toUpperCase();
vows = caps.replace('A','Z');
vows1 = vows.replace('E','Z');
vows2 = vows1.replace('I','Z');
vows3 = vows2.replace('O','Z');
vows4 = vows3.replace('U','Z');
}
public void setOrd()
{
//this is where the reversing thing is suppose to be but i dunno how to do it...???
}
public String getFinal()
{
return vows4;
}
}
thanks!