Tuesday, March 17, 2009

exerCise #4: Name Echo

ExerCise #4: Name Echo

//ProgrammerName: Reuben D. matiga
//ProgramName: Name Echo
//Purpose: To Learned more in java
//Date: March 17,2009
//Instructor: Dony Dongiapon



import java.util.Scanner;
import java.io.*;
public class reverse {
   
 
  public static void main(String[] args) throws IOException
  {
  // The normal sentence that is going to be reversed.
  System.out.print("Enter your Name: ");
  Scanner in=new Scanner(System.in);
  String words = in.nextLine();
   
  String reverse2="";
   
  String Word1=words.substring(words.indexOf(" "),words.length()).toUpperCase();
  String Word2=words.substring(0,words.indexOf(" "));
   
  // Print the normal string
  System.out.println("Normal : " + words);
 // Print the string in reversed order
  System.out.println("Reverse: " +Word2+ " "+Word1);
  }

}

INPUT:
reuben matiga

OUTPUT:

reuben MATIGA

No comments:

Post a Comment