用Java编写一程序
来源:百度知道 编辑:UC知道 时间:2024/06/04 18:25:03
完整程序见下,记得采用啊:
import java.util.*;
class MinusException extends ArithmeticException {
public MinusException() {
}
public MinusException(String str) {
super(str);
}
}
class OverException extends ArithmeticException {
public OverException() {
}
public OverException(String str) {
super(str);
}
}
public class TestScore {
public static void judgescore(int i) throws MinusException, OverException {
if (i < 0)
throw new MinusException("分数不能为负数");
if (i > 100)
throw new OverException("分数超过100,过大!");
}
public static void main(String[] args) {
int array[] = { 0, 0 };
int turn = 1;
double total = 0;
Scanner input = new Scanner(System.in);
int score = 0;
System.out.println("请输入学生成绩,输入-1退出:");
System.out.print("请