importjava.math.BigDecimal;publicclassDouble{ publicDouble(){ } publicstaticvoidmain(Stringargs[]){ Stringdata[]={"15:33","14:...
import java.math.BigDecimal;public class Double { public Double() { } public static void main(String args[]){ String data[] = {"15:33","14:55"}; float a[] = new float[data.length]; for(int i=0;i< data.length;i++){ String temp[] = data[i].split(":"); float m1 = (float)Integer.parseInt(temp[0]); float m2 = (float)Integer.parseInt(temp[1]); a[i] = m1+m2/60; int scale = 2; int roundingMode = 4; BigDecimal bd = new BigDecimal((float)a[i]); bd = bd.setScale(scale,roundingMode); a[i] = bd.floatValue(); System.out.println(a[i]); } int i = 0; double time = 0; while(i
展开