String protein = dna.substring(start, stop+3);
System.out.println("Protein: " + protein);
} else {
System.out.println("No protein.");
}
guessing this was just mislabled and should have been marked “Protein”
or the code should have added a different check:
if (start != 0 &&
stop != -1 &&
(stop - start) % 3 == 0)
Contains the start codon ATG and index 6 and stop codon TGA at index 12 and has 3 nucleotides TAC between them, which is divisible by 3, which makes them a protein by the definition provided in the Objective…
"A protein has the following qualities:
It begins with a “start codon”: ATG.
It ends with a “stop codon”: TGA.
In between, each additional codon is a sequence of three nucleotides."
Which conflicts with the solution…
"Let’s test your code with each DNA strand. These should be the results:
dna1: Protein.
dna2: Not a protein.
dna3: Not a protein."
It isn’t explicitly stated in the instructions that you have to create a primary condition in the if/else statement to test the String for its beginning and end.
So IF your string starts with “ATG” AND ends with TGA then you move onto the next condition.