Exer #1: Word Reverser
Programmer Name: Dongiapon, Jenelyn E.
Program name: Word Reverser
Date: March 16, 2009
Instructor: Mr. Dony Dongiapon
public class Reverse
{
public static void main(String[] args)
{
// Sentence that is going to be reversed:
String words = "Reverse this word:";
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 normal string
System.out.println("Normal : " + words);
// Print string in reversed order
System.out.println("Reverse: " +reverse2+ " "+reverse);
}
}
Friday, March 20, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment