You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
643 B
32 lines
643 B
package kr.co.kihyun.math; |
|
|
|
public class SumUtil { |
|
|
|
public static String[] sum(String[][] data) { |
|
int count = 0; |
|
int count2 = 0; |
|
double sumField = 0.0D; |
|
String[] sumData = null; |
|
|
|
count = data.length; |
|
if (data != null) { |
|
count2 = data[0].length; |
|
} |
|
|
|
sumData = new String[count2]; |
|
|
|
for (int i = 0, j = 0; i < count2; i++) { |
|
for (j = 0; j < count; j++) { |
|
try { |
|
sumField += Double.parseDouble(data[j][i].trim()); |
|
} catch (NumberFormatException ex) { |
|
System.err.println("NumberFormatException : " + ex); |
|
} |
|
} |
|
sumData[i] = Double.toString(sumField); |
|
sumField = 0.0D; |
|
} |
|
|
|
return sumData; |
|
} |
|
}
|
|
|