//Final Exercises
/*
ProgramName: Word Reverser
Purpose : To make a program that will print out word that will be reverse in it's original order.
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();
// Print the normal string
System.out.println("Normal : " + words);
// Print the string in reversed order
System.out.println("Reverse: " +reverse2+ " "+reverse);
}
}
No comments:
Post a Comment