题解 | #判断学生成绩#

判断学生成绩

https://www.nowcoder.com/practice/a35cbafbec10449f8a576e822430a3ab

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int score = scanner.nextInt();

        //write your code here......
        try {
            if (score >= 0 && score <= 100) {
                System.out.println(score);
            } else {
                throw new ScoreException("分数不合法");
            }
        } catch (ScoreException se) {
            System.out.println(se.getMessage());
        }
    }
}

class ScoreException extends Exception {

    //write your code here......
    public ScoreException(String msg) {
        super(msg);
    }

}

全部评论

相关推荐

瑞雪兆丰年_:可以贴个超级大的校徽,以防HR眼拙
点赞 评论 收藏
分享
迷茫的大四🐶:摊牌了,我是25届的,你们也不招我
点赞 评论 收藏
分享
评论
点赞
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务