Math.round函数是默认加上0.5之后,向下取整。
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double d= scanner.nextDouble();
//write your code here......
int i=(int)Math.round(d);
// int i=(int)d;
System.out.println(i);
}
}