DNA Program
Description
The genetic information in DNA is encoded as a sequence of four chemical bases:
Adenine(A)
Guanine(G)
Cytosine(C)
Thymine(T)
Guanine(G)
Cytosine(C)
Thymine(T)
This program inputs a DNA sequence and calculates the GC content.
Associated Concepts:
String
Algorithm:
main method:
Method gcContent definition
Input a DNA sequence from the keyboard
Call gcContent method and pass the argument to get the result
Print the result
Call gcContent method and pass the argument to get the result
Print the result
Method gcContent definition
Declare variable gcCount and initialize it to 0
Loop: go through each letter in the DNA sequence
Retrieve the letter at index i
If the letter is G or C
Increment the count
Calculate and return the GC-content
Loop: go through each letter in the DNA sequence
Retrieve the letter at index i
If the letter is G or C
Increment the count
Calculate and return the GC-content