Hey there! This problem might be a bit unpredictable, but give it a go and let us know how you do!
Create a program that analyzes a DNA sequence and calculates the percentage of each nucleotide (A, C, G, T) in the sequence. Fill in the blanks in the code to count the occurrences of each nucleotide and display the percentages.Processing strings
Unraveling the genetic tapestry
Report a typo
Fill in the gaps with the relevant elements
dnaSequence = "ATCGCGATCGATCGATCG";
int a = 0, c = 0, g = 0, t = 0;
(int i = 0; i < dnaSequence.length(); i++) {
char nucleotide = dnaSequence.(i);
(nucleotide == 'A') a++;
if (nucleotide == 'C') c++;
else if (nucleotide == 'G') g++;
else if (nucleotide == 'T') t++;
}
int total = dnaSequence.length();
System.out.printf("A: %.2f%%\nC: %.2f%%\nG: %.2f%%\nT: %.2f%%\n",
(double)a/total*100, (double)c/total*100, (double)g/total*100, (double)t/total*100);Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.