Wednesday, March 18, 2009

Exercise4- Name Echo

/*Programmer: Miexie D. Tulid
 *Date started: March 13, 2009
 *Date ended: March 18, 2009
 *Description: A program that reads a full name the user and prints it out w/ the same word in firstname

 but upper case in last name.*/


 import java.util.Scanner;
public class NameEcho{
public static void main(String args[]){

Scanner scan=new Scanner(System.in);
String name;
String fname;
String lname;

System.out.println("Enter your name:");
name=scan.nextLine();
int x=name.indexOf(" ");
fname=name.substring(0,x);
lname=name.substring(x);
System.out.printf("\n%s %s\n",fname,lname.toUpperCase());

}
}

No comments:

Post a Comment