-
Notifications
You must be signed in to change notification settings - Fork 0
/
PangramChecker.java
39 lines (26 loc) · 960 Bytes
/
PangramChecker.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
package arrayslogical;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class PangramChecker {
public static boolean isPangram(String sentence) {
sentence = sentence.replaceAll(" ", "").toLowerCase();
Set<Character> characters = new HashSet<>();
for (char c : sentence.toCharArray()) {
if (Character.isLetter(c)) {
characters.add(c);
}
}
return characters.size() == 26;
}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a sentence: ");
String sentence = scanner.nextLine();
if (isPangram(sentence)) {
System.out.println("The sentence is a pangram.");
} else {
System.out.println("The sentence is not a pangram.");
}
}
}