Tuesday, March 17, 2009

Exercise no.4 (ECHO)

/*
ProgrammerName: Dandy A. Macaubos
ProgramName       :  Echo
Purpose                  : to make a  program that echo's name problems
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 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);
  }

No comments:

Post a Comment