java提交后一直显示返回非零怎么办

class Main {

public static void main(String args[]) {
GetScore m=new GetScore();
String score="数学87分,物理86分,英语97分";
m.getScore(score);
}
}
/* 请在这里填写答案 */
这是我写的
class GetScore {
public static void getScore(String score) { String cost ="数学87分,物理86分,英语97分";
Scanner scanner = new Scanner(cost);
scanner.useDelimiter("[^0123456789.]+");
double sum=0;
int count =0;
while(scanner.hasNext()){
try{ double a = scanner.nextDouble();
count++;
sum = sum+ a;
}
catch(InputMismatchException exp){
String t = scanner.next();
}
} System.out.print("总成绩:"+sum+";");
System.out.println("平均分数:"+sum/count);
}
}

目的是啥啊,计算总分和平均分吗,按照你的思路简单修改了一下

import java.util.InputMismatchException;
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        GetScore m = new GetScore();
        String score = "数学87分,物理86分,英语97分";
        m.getScore(score);
    }
}

/* 请在这里填写答案 */
class GetScore {
    public void getScore(String score) {
        Scanner scanner = new Scanner(score);
        scanner.useDelimiter("[^0123456789.]+");
        double sum = 0;
        int count = 0;
        while (scanner.hasNext()) {
            try {
                double a = scanner.nextDouble();
                count++;
                sum = sum + a;
            } catch (InputMismatchException exp) {
                scanner.next();
            }
        }
        System.out.print("总成绩:" + sum + ";");
        System.out.println("平均分数:" + sum / count);
        scanner.close();
    }
}

package csdn008;

import java.util.InputMismatchException;
import java.util.Scanner;

/**
 * @author wangfei
 * @version 1.0
 * @date 2022/6/5
 */
class Main {

    public static void main(String[] args) {
        String score="数学87分,物理86分,英语97分";
        GetScore.getScore(score);
    }
}

class GetScore {
    public static void getScore(String score) {
        Scanner scanner = new Scanner(score);
        scanner.useDelimiter("[^0123456789.]+");
        double sum=0;
        int count =0;
        while(scanner.hasNext()){
            try{ double a = scanner.nextDouble();
                count++;
                sum = sum + a;
            }
            catch(InputMismatchException exp){
                String t = scanner.next();
            }
        }
        System.out.print("总成绩:"+sum+";");
        System.out.println("平均分数:"+sum / count);
    }
}


mark