Results 1 to 8 of 8

Thread: What?!?!

  1. #1
    ErikD99 is offline Member
    Join Date
    Oct 2010
    Posts
    13
    Rep Power
    0

    Default What?!?!

    Ok so i compile this code and it tells me that "class, interface, or enum expected".

    It says that the error is in the very last line of the code. the closing bracket-----> "}"

    i dont get why.. and body have an idea?

    Java Code:
    /*
     * COMP 1010 Section A06
     * Instructor: Christina Penner
     * Assignment: Assignment 3, question 2
     * @author:		 Erik Danielson
     */
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.util.Scanner;
    import javax.swing.JFileChooser;
    
    //assignment name
    public class QA3Q2
    {
    
        private static Scanner scanner;
        private static File fastaFile;
        private static JFileChooser chooser;
        private static StringBuilder sb;
        private static int count;
    
        	public static void main(String[] args) {
    
            	getFile();
            	int aPercentage;
            	int cPercentage;
            	int gPercentage;
            	int tPercentage;
    
    			chooser = new JFileChooser();
    
    					// making sure OK was pressed.
    			    	if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
    
    						// opens selected file
    			          	fastaFile = chooser.getSelectedFile();
    
    			           	return fastaFile;
    			        }
    
    			        return null;
    
    
    
            	if (fastaFile != null) {
    
    				// print message and get next input
                	System.out.printf("%1$s\r\n", getHeader(fastaFile));
    
            	} else {
    
                	System.out.println("Invalid FASTA file.");
            	}
    			aPercentage = (aTotal / getSequence.length);
    			cPercentage = (cTotal / getSequence.length);
    			gPercentage = (gTotal / getSequence.length);
    			tPercentage = (tTotal / getSequence.length);
    
    			printDNAHistogram();
    
    		}
    
    		public static String getHeader(File file) {
        	    if (file != null) {
        	        try {
    
                    	scanner = new Scanner(file);
    
                    // returns file you chose without > symbol
                    return scanner.nextLine().substring(1,
                            scanner.nextLine().length() - 1);
    
                	}catch (FileNotFoundException fnf) {
    
                    		fnf.printStackTrace();
    
                	} finally {
    
                		//closes scanner object
                    	if (scanner != null) {
    
                			scanner.close();
        	    	        }
        	    	    }
        	    	}
    
            		return null;
        		}
    		//prints file without first line in it.
        	public static String getSequence(File file) {
        	    if (file != null) {
        	       	try {
    
        	            sb = new StringBuilder();
        	            scanner = new Scanner(file);
    
        	            while (scanner.hasNextLine()) {
        	                if (!scanner.nextLine().contains(">")) {
        	                    sb.append(scanner.nextLine());
        	                }
        	            }
    
        	            return sb.toString();
        	        	} catch (FileNotFoundException fnf) {
        	            fnf.printStackTrace();
        	        	} finally {
        	            // closes scanner
        	            if (scanner != null) {
        	                scanner.close();
        	            }
        	        }
        	    }
    
        	    return null;
        	}
    		//goes through all the letter and keeps a running total for each.
        	public static int countBase(String getSequence, char base) {
    
        	    int aTotal= 0;
        	    int cTotal= 0;
        	    int gTotal= 0;
        	    int tTotal= 0;
        	    for (int i = 0; i < getSequence.length(); i++) {
        	        if (getSequence.charAt(i) == 'A') {
        	            aTotal= aTotal+1;
        	        }
        	        else if (getSequence.charAt(i) == 'C') {
        	           cTotal= cTotal+1;
    				}
    				else if (getSequence.charAt(i) == 'G') {
        	            gTotal= gTotal+1;
    				}
    				else if (getSequence.charAt(i) == 'T') {
        	            tTotal= tTotal+1;
    				}
    			}
    
        	    return count;
    
    	  	}
    
    
    		public static void printDNAHistogram(String getHeader, int aPct, int
    		cPct, int gPct, int tPct) {
    
    			system.out.println(getHeader);
    
    			printBar();
    
    		}
    
    		public static void printBar(String label, int percent, char barSymbol) {
    
    				System.out.println("A: ");
    				for(i=0; i<aPct; i++){
    					System.out.println("=");
    				}
    				System.out.println(aPct);
    
    				System.out.println("C: ");
    				for(i=0; i<cPct; i++){
    					System.out.println("=");
    
    				}
    				System.out.println(cPct);
    
    				System.out.println("G: ");
    				for(i=0; i<gPct; i++){
    					System.out.println("=");
    
    				}
    				System.out.println(gPct);
    
    				System.out.println("T: ");
    				for(i=0; i<tPct; i++){
    					System.out.println("=");
    
    				}
    					System.out.println(tPct);
    
    		}
    
       	}
    
    }

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,234
    Rep Power
    19

    Default

    Recommended reading: How To Ask Questions The Smart Way

    db

  4. #4
    mine0926 is offline Senior Member
    Join Date
    Apr 2010
    Location
    Philippines
    Posts
    580
    Rep Power
    5

    Default

    Is it just me? I think ErikD99 should reply in this thread Help!!! and should not create a new thread regarding this one...

    Also What?!?! does not describe his problem.
    Last edited by mine0926; 11-17-2010 at 04:25 AM.

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by Darryl.Burke View Post
    Recommended reading: How To Ask Questions The Smart Way

    db
    Hey Darryl. Yeah, his subject header is not exactly meaningful nor informative. Hopefully he'll do better with this next thread.

  6. #6
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by mine0926 View Post
    Is it just me? I think ErikD99 should reply in this thread Help!!! and should not create a new thread regarding this one...

    Also What?!?! does not describe his problem.
    I will send him a private message asking him not to create new threads before responding to responses made in previous threads. This behavior will not encourage folks to continue to help him.

  7. #7
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,234
    Rep Power
    19

    Default

    Quote Originally Posted by Fubarable View Post
    I will send him a private message asking him not to create new threads before responding to responses made in previous threads. This behavior will not encourage folks to continue to help him.
    Looks like he took that to mean he should create a new user account.
    Java Forums - View Profile: Student101

    db

  8. #8
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,513
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote Originally Posted by Darryl.Burke View Post
    Looks like he took that to mean he should create a new user account.
    Java Forums - View Profile: Student101
    Anything wrong with that, hm?

    kind regards,

    Loretta
    cenosillicaphobia: the fear for an empty beer glass

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •