/* The user will be prompted to enter the first, middle, and last name of a person as one string, from th keyboard. The user will use the appropriate String methods, including indexAt(), to determine the first, middle, and last initial from the source String entered by the user. Used to demonstrate String methods author: course: 15-100 Intro to Java Programming section: date: 5/29/01 */ /* Activity list 1. read the entire name from the screen.. how do you do that? Show example 2. We have to extract first, middle and last names from this. need s method: to break the name by blank. */ import java.io.*; import javax.swing.JOptionPane; public class NameInitials { public static void main(String args[]) { String fullName; fullName = JOptionPane.showInputDialog("Please enter your full name"); int k1 = fullName.indexOf(" "); String next = fullName.substring(k1 + 1, fullName.length()-1); int k2 = next.indexOf(" "); String initials; String firstInit, middleInit, lastInit; firstInit = fullName.substring(0,1); middleInit = next.substring(0, 1); lastInit = next.substring(k2+1, k2+2); /* Use the appropriate String methods, including indexAt() to find the first, middle, and last initial from the source string entered by the user from the keyboard */ initials = firstInit+ middleInit + lastInit; System.out.println(initials.toLowerCase()); } }