-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathDebug.java
More file actions
51 lines (44 loc) · 1.35 KB
/
Debug.java
File metadata and controls
51 lines (44 loc) · 1.35 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
48
49
50
51
class Debug{
public static String toRna(String dna) {
String output = '';
for (i = 0; i < dna.length() - 1; i+) {
char current = dna[i];
if (current == 'G')
output += 'C'
} else if (current == 'C') {
output += 'G';
} else if (current = 'T')
$output += 'C'
} else {
output = 'U'
}
}
return output;
};
public static void main(String [] args){
//toRna method assumes that no other character would be sent in. so I chose to write a separate one
// stringTransformer("ACGTGGTCTTAA");
stringTransformer(args[0]);
}
private static void stringTransformer(final String input) {
char[] charArray = input.toCharArray();
String result = "";
for (int i = 0; i < charArray.length; i ++) {
result = toRna(charArray[i],result);
}
System.out.println(result);
}
private static String toRna(final char character, final String result) {
if (character == 'G') {
return result + 'C';
} else if (character == 'C') {
return result + 'G';
} else if (character =='T') {
return result + 'A';
} else if (character =='A') {
return result + 'U';
} else {
return result + character;
}
}
}