Wednesday, March 18, 2009

Exercise4: Name

Exercise4: Name
/*Programmer:Rosedil Mae P. Mobreros
*Date started: March 15, 2009
*Date ended: March 18, 2009
*Purpose: To create a program that will read and print the full name of the user. The first name will remain the same as the way the user had entered, but the last name should be changed into upper case.*/

import java.util.Scanner;
public class Name
{

public static void main(String args[])
{

Scanner scan=new Scanner(System.in);
String fullname;
String firstname;
String lastname;

System.out.println("Please enter your full name:");
name=scan.nextLine();
int roxy=name.indexOf(" ");
firstname=name.substring(0,roxy);
lastname=name.substring(roxy);
System.out.printf("\n%s %s\n",firstname,lastname.toUpperCase());

}
}

No comments:

Post a Comment