Results 1 to 8 of 8
Thread: What?!?!
- 11-17-2010, 03:38 AM #1
Member
- Join Date
- Oct 2010
- Posts
- 13
- Rep Power
- 0
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); } } }
-
Count your curly braces. Do you have one too many or too few?
- 11-17-2010, 04:19 AM #3
Recommended reading: How To Ask Questions The Smart Way
db
- 11-17-2010, 04:23 AM #4
Senior Member
- Join Date
- Apr 2010
- Location
- Philippines
- Posts
- 580
- Rep Power
- 4
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.
-
-
- 11-18-2010, 05:48 AM #7
Looks like he took that to mean he should create a new user account.
Java Forums - View Profile: Student101
db
- 11-18-2010, 07:32 AM #8
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,377
- Blog Entries
- 7
- Rep Power
- 17


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks