Friday 3 August 2012

WAP to print a string such that , if input string is "hello how are you and where are you good " then out put is "doog era dna era olleh how you where you" and if input is " hello how are you and where are you good one" then out put is "eno uoy erehw uoy woh hello are and are good".


import java.util.StringTokenizer;


public class stringTokenTest {
public static void main(String[] args) {
String str = "hello how are you and where are you good one";
String delim = " ,;?'#%&*";
StringBuilder build = new StringBuilder();
StringBuilder string = null;
String s;
StringTokenizer token = new StringTokenizer(str, delim);
while (token.hasMoreElements()) {
s = token.nextToken();
string = build.append(" " + s).reverse();
}
System.out.println(string);
}


}



NOTE: implement it in C language without using built-in function