0

Please help. I have an illegal start of expression at line 65 where it says "public static void p(Object...args)"

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
import java.io.*;

/**
 *
 * @author Minh
 */
public class Dna {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws Exception 
    {

        BufferedReader r = new BufferedReader (new FileReader("a1input.txt"));

        String line = r.readLine();

        int howMany = Integer.parseInt (line)*2;
        int ctr = 0;

        String firstStrand = null;
        String secondStrand = null;
        String result = null;

        while (ctr <= howMany && line !=null)

        {
            line = r.readLine ();
            ctr++;
            if(line !=null)
            {
                if(ctr%2 == 0)
                {
                    secondStrand = line;

                    p(firstStrand, "and\n",secondStrand, "=\n",isHelix (firstStrand, secondStrand)?"YES" : "NO");
                }

                else 
                {
                    firstStrand = line;
                }
            }
        }
            //"A" always bonds with "T"
            //"G" always bonds with "C"
            //p(isHelix("ATTCGAA", "TAAGCTT"));
            //p(isValidStrand (args [0]));

            /*
            p(isValidBond('A','T'),'\n',isValidBond('T','A'),
            * '\n',isValidBond('G','C'),'\n',isValidBond('C','G'),'\n', isValidBond('C','A'),
            * '\n',isValidBond('A','C'),'\n',isValidBond('G','T'),'\n',isValidBond('T','G'));
            */

       /**
     *

     */
    public static void p(Object...args)
        {
           StringBuilder s = new StringBuilder ();
           for (int i=0; i < args.length; i++) {
                s.append ( args [ i ] );
            }
           System.out.println ( s.toString () );

        }

    public static boolean isHelix(String dna1,String dna2)
       {
           if(dna1.length()!= dna2.length()) {
               return false;
           }

           for(int i=0; i<dna1.length(); i++)
           {
               if(!isValidBond (dna1.charAt (i), dna2.charAt (i))) 
               {
                   return false;
               }
           }
           return true;
       }

       public static boolean isValidBond(char first,char second)
       {
           //"A" always bonds with "T"
           //"G" always bonds with "C"
           boolean result = false;

           if(first =='A' && second =='T'||first == 'T'&&second == 'A') {
               result = true;
           }

           else if ( first == 'G' &&second == 'C' ||first == 'C' &&second == 'G' ) {
               result = true;
           }
           else {
               result = false;
           }

           /* 
           p ( "isValidUniqueSequence ( ", first,second, " ) returns ", result ); 
           */
            return result;

       }
    }
3
Contributors
2
Replies
13
Views
4 Years
Discussion Span
Last Post by stultuske
Featured Replies
  • 1

    also: don't let your main method throw Exceptions. sure your code 'll compile and run, but where do you plan to catch that Exception? Read More

1

also: don't let your main method throw Exceptions. sure your code 'll compile and run, but where do you plan to catch that Exception?

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.