-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPangrams.java
More file actions
47 lines (44 loc) · 1.26 KB
/
Pangrams.java
File metadata and controls
47 lines (44 loc) · 1.26 KB
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
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
public class Pangrams {
public Pangrams(String filename) throws IOException {
BufferedReader br = new BufferedReader(new FileReader(filename));
String str;
int i;
int flag;
char ch;
char[] pangram = new char[26];
while ((str = br.readLine()) != null) {
for (i = 0; i < 26; i++) {
pangram[i] = '0';
}
flag = 0;
for (i = 0; i < str.length(); i++) {
if (str.charAt(i) >= 'a' && str.charAt(i) <= 'z') {
pangram[str.charAt(i) - 'a'] = '*';
} else if (str.charAt(i) >= 'A' && str.charAt(i) <= 'Z') {
pangram[str.charAt(i) - 'A'] = '*';
}
}
for (i = 0; i < 26; i++) {
if (pangram[i] == '0') {
ch = (char) ('a' + i);
System.out.print(ch);
flag = 1;
}
}
if (flag == 0) {
System.out.print("NULL");
}
System.out.println();
}
}
public static void main (String[] args) throws IOException {
if (args.length != 1) {
System.out.println("Insufficient number of parameters passed. Exiting.");
System.exit(1);
}
Pangrams pg = new Pangrams(args[0]);
}
}