-1

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();        
       }
  }
}
}
Nathan Tuggy
  • 2,237
  • 27
  • 30
  • 38
Jenna
  • 21
  • 2

2 Answers2

1
  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.
Prashant
  • 1,002
  • 13
  • 29
-1

You can't pass that non static string to a static function. mark the string as static and it'll work.

Dici
  • 25,226
  • 7
  • 41
  • 82
Justin
  • 24
  • 6
  • i assumed c++ cause s was lowercase. i cant comment yet so i do my best with guessing from context. – Justin Oct 03 '15 at 02:36
  • it was java! thankyou so much anyway :) – Jenna Oct 03 '15 at 02:48
  • 1
    Well, you should delete this answer, because it is completely wrong. This can happen due to the misinterpretation of the used language, but it won't help anybody. – Tom Oct 04 '15 at 13:46