Java subString&deleteChatAt在此题下无法正确运行?

理论上是没问题的啊
却提示说q是一个String,不是String玩个屁啊。

import java.io.IOException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws IOException {
        int he = 0;
        String Shibiema = "";
        
        Scanner sc = new Scanner(System.in);
        String c = sc.nextLine();
        
        String q = c; 
                q.deleteCharAt(q.length()-1);
        
        String allNum = c.replace("-", "");
        allNum.deleteCharAt(c.length()-1);
        String LAST = String.valueOf(allNum.charAt(c.length() - 1));
        for(int i=0; i<allNum.length(); i++) {
            String thisn = String.valueOf(allNum.charAt(i));
            int chengji = Integer.valueOf(thisn) * (i+1);
            he += chengji;
        }
        int yushu = he%11;
        
        if(yushu == 10) {
            Shibiema = "X";
        } else {
            Shibiema = String.valueOf(yushu);
        }
        
        if(Shibiema == LAST) {
            System.out.println("Right");
        } else {
            String theRightCode = q + Shibiema;
            System.out.println(theRightCode);
        }
    }
}

0 条评论

目前还没有评论...

信息

ID
1484
难度
5
分类
字符串 点击显示
标签
递交数
13357
已通过
4713
通过率
35%
被复制
10
上传者