working on class project, having trouble data after read array.
in excel spreadsheet, need read straight down column paying attention first digit in each block. when split column continuous string no space can't figure out how count first digit opposed counting each digit (as code now). example: (11, 20, 296) split, becoming "1120296"
final int[] benfordlaw = {0, 30, 18, 13, 10, 8, 7, 6, 5, 5}; int[] actualprecent = new int[10]; int benfordscore = 0; float[] countfornum = new float[10]; float totalcount = 0; //this while loop read through each line of file while (scan.hasnextline()) { // statement reads in next line of file. string line = scan.nextline(); string[] values = line.split(",(?=(?:(?:[^\"]*+\"){2})*+[^\"]*+$)"); //12-15 column #'s (int = 12; < 15; ++i) { (int j = 0; j < values[i].length(); j++) { char chara = values[i].charat(j); (int k = 1; k <= 9; ++k){ char compare = (char)(k + '0'); if (chara == compare) { ++countfornum[k]; ++totalcount; } } } } }
i think didn't totally question, hope helps
example: (11, 20, 296) split, becoming "1120296" => if want 11 in text
read line , string sol 1. ) a) remove first , last char b) split.text , trim it. c) first one
sol 2. ) use regex , first element ex regex.) ([0-9]*),
good luck
Comments
Post a Comment