//ProgrammerName: Reuben D. matiga
//ProgramName: Word Reverser
//Purpose: To Learned more in java
//Date: March 17,2009
//Instructor: Dony Dongiapon
public class reverse
{
public static void main(String[] args)
{
// The normal sentence that is going to be reversed.
String words = "Go to the main menu";
String reverse2="";
String reverse = new StringBuffer(words).reverse().toString();
String Word1=words.substring(words.indexOf(" "),words.length());
reverse= new StringBuffer(Word1).reverse().toString();
String Word2=words.substring(0,words.indexOf(" "));
reverse2=new StringBuffer(Word2).reverse().toString();
System.out.println("Normal : " + words);
System.out.println("Reverse: " +reverse2+ " "+reverse);
}
}
No comments:
Post a Comment