Each nucleotide has a complement: for 'a' it is 't' (and vice
versa) and for 'c' it is 'g' (also vice versa).
Although this complementarity is a
chemical process, you'll write code to produce a digital complement
for a strand. For a given strand of DNA represented as a string, return
the complement of the strand, also as a string.
Definition
Class: DNAComplement
Method: complement
Parameters: String dna
Returns: String
Method signature:
String complement(String dna)
(be sure your method is public)
Class
public class DNAComplement
{
public String complement(String dna)
{
// fill in code here
}
}
Notes
Constraints
The String dna will contain at most 50 characters.
The characters of dna will be from 'a', 'g', 't', 'c',
all lower-case.