I have four arrays of size 8 each with DNA bases assigned (A T G or C).
In a method I have to pass a base, in this case A and compare all the positions of each arrays and determine how many 'A' are in each position of each array. And then return an array with the totals, which would also be size 8.
I'm having trouble comparing each positions to the base... :S This is just part of my code without the other methods included...I just need help with that one.thanks! and i know it's wrong.I've tried it so many ways :/
import java.io.*; import java.util.*; public class Lab6 { public static void main(String[] args) throws FileNotFoundException { Scanner inFile = new Scanner(new File("seq.txt")); //text data file with DNA bases char base = 'A'; //base passed to countBase method int size = 8; //size of the arrays char[] array1 = new char[size]; //first array with 8 indexes char[] array2 = new char[size]; //second array with 8 indexes char[] array3 = new char[size]; //third array with 8 indexes char[] array4 = new char[size]; //fourth array with 8 indexes int i = 0; while(inFile.hasNext()) { array1[i] = inFile.next().charAt(0); array2[i] = inFile.next().charAt(0); array3[i] = inFile.next().charAt(0); array4[i] = inFile.next().charAt(0); i++; } System.out.println(array1); System.out.println(array2); System.out.println(array3); System.out.println(array4); int[] result = countBase(array1, array2, array3, array4, base); int mostIndex = findMost(result); double average = computeAvg(result); System.out.println(result); System.out.println("The largest value in the counter array is " + result[mostIndex]); System.out.println("The average for the counter array is " + average); } public static int[] countBase(char[] one, char[] two, char[] three, char[] four, char letter) //count number of times a base appears { int[] counter = new int[8]; int sum = 0; for(int i = 0; i < one.length; i++) { if(letter == one[i] || letter == two[i] || letter == three[i] || letter == four[i]) { sum++; } } return counter;