-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDNA.java
More file actions
26 lines (25 loc) · 719 Bytes
/
DNA.java
File metadata and controls
26 lines (25 loc) · 719 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
26
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class DNA {
public static void main(String[] args) throws java.io.IOException {
int a, c, g, t;
a = c = g = t = 0;
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
int ch;
while ((ch = in.read()) != -1) {
ch = (char)ch;
if (ch == 'A') {
a += 1;
} else if (ch == 'C') {
c += 1;
}
else if (ch == 'G') {
g += 1;
}
else if (ch == 'T') {
t += 1;
}
}
System.out.printf("%d %d %d %d\n", a, c, g, t);
}
}