forked from profjpbaugh/complete-java-developer-course
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNameParser.java
More file actions
25 lines (18 loc) · 735 Bytes
/
Copy pathNameParser.java
File metadata and controls
25 lines (18 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import java.util.Scanner;
public class NameParser {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
String fullName;
String firstName;
String lastName;
System.out.println("What is your full name?");
fullName = keyboard.nextLine();
int indexOfSpace = fullName.indexOf(" ");
firstName = fullName.substring(0, indexOfSpace);
lastName = fullName.substring(indexOfSpace + 1);
firstName = firstName.toUpperCase();
lastName = lastName.toLowerCase();
System.out.println("First name is " + firstName);
System.out.println("Last name is " + lastName);
}//end main
}