-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringTask8.java
More file actions
26 lines (16 loc) · 764 Bytes
/
Copy pathStringTask8.java
File metadata and controls
26 lines (16 loc) · 764 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 StringTask8 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a line of text: ");
String enteredText = scanner.nextLine();
String[] arrayOfWords = enteredText.split(" ");
System.out.println("Words beginning with a capital letter:");
for (int currentIndex = 0; currentIndex < arrayOfWords.length; currentIndex++) {
char firstCharacter = arrayOfWords[currentIndex].charAt(0);
if (firstCharacter >= 'A' && firstCharacter <= 'Z') {
System.out.println(arrayOfWords[currentIndex]);
}
}
}
}