-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConstructID.java
53 lines (43 loc) · 1.18 KB
/
ConstructID.java
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//Chapter 7: Exercise #11
//Filename: ConstructID.java
//Programmer: Nick DeVos
//Date: 11/30/17
import java.util.Scanner;
public class ConstructID
{
public static void main(String[] args)
{
String fullName;
String streetAddress;
StringBuilder userID = new StringBuilder("");
Scanner keyboard = new Scanner(System.in);
System.out.println("Please enter your full name");
fullName = keyboard.nextLine();
System.out.println("Please enter your street address");
streetAddress = keyboard.nextLine();
userID.append(fullName.charAt(0));
int count = 0;
while(count < fullName.length())
{
if(fullName.charAt(count) == ' ')
{
userID.append(fullName.charAt(count + 1));
}
count++;
}
count = 0;
while(count < streetAddress.length())
{
if(streetAddress.charAt(count) != ' ')
{
userID.append(streetAddress.charAt(count));
}
else
{
count = streetAddress.length();
}
count++;
}
System.out.println("ID: " + userID);
}
}