public class DayFive16 {
public static void main(String[] args) {
double num = 5.45;
int i = si(num);
System.out.println(num + "四舍五入后的值是:" + i);
}
public static int si(double num){
int a = (int)(num*10%10);
System.out.println(a);
if(a>4){
return (int)num+1;
}else{
return (int)num;
}
}
}"取绝对值"package com.itheiam;
public class DayFive15 {
public static void main(String[] args) {
double num = jue(-100);
System.out.println("绝对值是:"+ num);
}
public static double jue(double num){
if(num<0){