I'm trying to print an array using printf to round each index in the array. Heres the code:
This should create a new array "percent" using the counts at each index from the array "counts". It works fine if I do "System.out.println(Arrays.toString(percent));" however, I don't get the percent rounded. But when I use printf, I'm doing %.1fpercent[]\n because I want to round to one decimal place after each number in each index in the array. But I get a weird error "Exception in
thread "main" java.util.IllegalFormatConversionException: f != java.lang.String". Before anyone says it, I don't want to round the percent[] array and have it be the number in the array, I need all the numbers later on for other calculations. I know I can do Math.round() but like I said, I need to keep the original numbers, that's why I'm doing printf, so I can just convert it when I need to round it.
While I'm at it, I'm trying to convert a
string of characters into an array. Basically, there is a string of proteins, labeled by one letter (4 proteins - a, c, g, and t). The string can look like "ATCGATTCCAACTCTTAA" What I'm trying to do is turn that string into an array: [ATC, GAT, TCC, AAC, TCT, TAA] so they are separated by three at a time with a '" , " and a space. Then I would like to print the array using "Arrays.toString();"
Sorry for being confusing. And thanks in advance!