加 0.5 取整。
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()) {
float number = sc.nextFloat();
System.out.println((int)(number + 0.5f));
}
sc.close();
}
}