import vo.Student; import java.math.BigDecimal; public class BigDecimalTest { public static void main(String[] args) { Student student = new Student(); student.setAge(20); student.setId("1"); student.setMath("100"); //获取成绩 BigDecimal bigDecimal = new BigDecimal(student.getMath()); //起投金额 String result = ""; //比较成绩是否大于 60 if (bigDecimal.compareTo(new BigDecimal(80)) >= 0){ //保留两位小数 String first = bigDecimal.divide(new BigDecimal(1)).setScale(2, BigDecimal.ROUND_DOWN).toString(); result = first + " 分"; } else { System.out.println("不及格"); } System.out.println(result); } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)