取近似值
取近似值
http://www.nowcoder.com/questionTerminal/3ab09737afb645cc82c35d56a5ce802a
import java.util.Scanner;
/**
@Author: zhouLai
@Date: 2020/3/24 21:22
@Version 1.0
/
public class Main {
/*\题目描述
写出一个程序,接受一个正浮点数值,输出该数值的近似整数值。如果小数点后数值大于等于5,向上取整;小于5,则向下取整。输入描述:
输入一个正浮点数值输出描述:
输出该数值的近似整数值*/
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
while (sc.hasNext()){System.out.println((int) Math.round(sc.nextDouble()));
}
}
}