题解 | #四舍五入#

四舍五入

http://www.nowcoder.com/practice/cae89de6292b4084acb93659353260e0

解题思路

考察基础函数,Math包下的round用于四舍五入,ceil用于向上取整,floor用于向下取整。

代码实现

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);

        System.out.println(i);
    }
}
全部评论
该牛油正在参与牛客写题解薅羊毛的活动,牛币,周边,京东卡超多奖品放送,活动进入倒计时!快来捡漏啦https://www.nowcoder.com/discuss/888949?source_id=profile_create_nctrack&channel=-1
点赞 回复 分享
发布于 2022-04-27 11:31

相关推荐

评论
10
3
分享

创作者周榜

更多
牛客网
牛客企业服务