Search code examples
javacompiler-errorsdna-sequencecannot-find-symbol

cannot find symbol...?


I have to write code that takes in a string of 3 letters and converts it to give the complement DNA (A==T, C==G AND REVERSE) string.

Although I think the code is okay, it keeps giving me the same error

"cannot find symbol"

At the string dna (main method), as well as twice in the method header of the watsonCrickTripletCompliment. Would anyone know where I am going wrong

public class DnaUtilities {      
  public static void main (String[] args) {  
    string dna = "AGT"; //cannot find symbol         
    System.out.println (watsonCrickTripletComplement(dna));
  }

  public static string watsonCrickTripletComplement (string dna) { /*cannot find symbol at both string*/
    StringBuilder builder = new StringBuilder();     
    if (dna.length() > 3 || dna.length() < 3 )
      return "";        
     else {
       for(int i=0; i<3; i++){
        char c = dna.charAt(i);
        if(dna.charAt(i) == 'T'){
            builder.append('A');
        }
        if(dna.charAt(i) == 'A'){
            builder.append('T');
        }
        if(dna.charAt(i) == 'C'){
            builder.append('G');
        }
        if(dna.charAt(i) == 'G'){
            builder.append('T');
        }   
    return builder.toString();        
       }
  }
}
}

Solution

    1. I am assuming this is Java, since you do not say what the language is.
    2. The word "string" is in lowsercase. You need to spell it String.