题解 | #判断学生成绩#
判断学生成绩
http://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.print(score);
}else throw new ScoreException("分数不合法");//抛出异常
}catch(ScoreException str){//捕捉异常
System.out.print(str.getMessage());//输出异常信息
}
}
}
class ScoreException extends Exception {
//write your code here......
public ScoreException(String message){
super(message);
}
}
曼迪匹艾公司福利 149人发布
查看24道真题和解析