/* Programmer: Norfe R. Gregorio * Program name: NameEcho * Subject: IT134_Computer Programming 3 * Instructor: Mr. Dony Dongiapon * Date Started: 03/16/09 * Date Finished: 03/19/09 * Purpose: To write a program that will asks for user's * name and then writes it back with the first name * as entered, and the second name all in capital letters. */
import java.*;
public class NameEcho{ public static void main(String[] args)throws StringIndexOutOfBoundsException{ try{ Scanner scan = new Scanner(System.in); System.out.println("Enter your name:"); String name = scan.nextLine(); int Big=name.indexOf(" "); int gib=Big++; String output = name.substring(0,Big); String name2=name.substring(gib,name.length()); System.out.print(output+" "+name2.toUpperCase()); } catch(StringIndexOutOfBoundsException index){ System.err.printf("No more data."); } }}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment