题解 | #取近似值#
取近似值
http://www.nowcoder.com/practice/3ab09737afb645cc82c35d56a5ce802a
public class Subject06 {
public static void main(String[] args) {
fun1();
}
private static void fun1(){
Scanner scanner = new Scanner(System.in);
String s = scanner.nextLine();
String[] split = s.split("\\.");
String s1 = "0."+split[1];
double v = Double.parseDouble(s1);
if (v>=0.5){
System.out.println((int)(Double.parseDouble(split[0])+1));
}else {
System.out.println((int)(Double.parseDouble(split[0])));
}
}
}