日期:2014-05-20  浏览次数:20794 次

麻烦大家帮我看看哦,哪里出错啦???
编写一程序,从文本域中输入一个班学生的某门课程成绩。统计及格人数、不及格人数、平均分。为此设计一个异常类,当输入的成绩小于 0分或大于 100时,抛出异常,程序中捕捉这个异常,并做出相应的处理(如弹出一信息框)。

我在eclipse里面编写的,代码如下:

package com.xy;
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("请输入" + turn + "个学生成绩:");
  score = input.nextInt();
  while (score != -1) {
  try {

  judgescore(score);
  if (score < 60)
  ++array[0];
  if (score >= 60)
  ++array[1];
  total += score;
  } catch (MinusException e1) {
  System.err.println(e1+"\n");
  } catch (OverException e2) {
  System.err.println(e2+"\n");
  } catch (ArithmeticException e3) {
  System.err.println("其它异常"+"\n");
  }
  turn++;
  System.out.print("请输入" + turn + "个学生成绩:");
  score = input.nextInt();
  }
  System.out.println("不及格人数:" + array[0]);
  System.out.println("及格人数:" + array[1]);
  System.out.println("平均分:" + total / (array[0] + array[1]));

 }
}
出错提示:java.lang.VerifyError: (class: com/xy/TestScore, method: main signature: ([Ljava/lang/String;)V) catch_type not a subclass of Throwable
Exception in thread "main" 
不懂是什么意思。

------解决方案--------------------
引用
我表示程序没有问题,估计是你编译的时候名字输错了之类的
问题解决classpath环境变量下有个路径,以前我设置的,下面有个cat.class

------解决方案--------------------
jdk版本问题...查查是不是版本...不匹配所引起的问题....