Bandysol
2022-07-22 20:35
采纳率: 100%
浏览 17

这个问题要如何解决?

package englishtest;
import java.util.*;
import java.io.*;
import threeonecher.*;

public class ruko {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("欢迎使用外研版英语单词记忆测评系统V1.0.0");
        System.out.println("‘1’为三年级");
        System.out.println("‘2’为四年级");
        System.out.println("‘3’为五年级");
        System.out.println("‘4’为六年级");
        System.out.print("请输入:");
        String a = scan.next();
        int fan = 100;
        int go = 1;
        for (;go <= 100;go += 1) {
        if (a.equals("1")) {
            int u = (int)(Math.random()*81);
            String l = String.valueOf(u);
            String b = "chinese." + l;
            System.out.print("请输入" + b + "的英文:");
            String sr = scan.next();
            String bb = "three." + l;
            if (sr.equals(bb)) {
            } else {
                fan -= 1;
            }
        }
        }
        if (!a.equals("1") && !a.equals("2") && !a.equals("3") && !a.equals("4")) {
            if (!a.equals("5") && !a.equals("6") && !a.equals("7") && !a.equals("8")) {
                System.out.println("错误!");
            }
        }
        System.out.println("得分;" + fan);
    }
}

题目我放到了另一个文件里:

package threeonecher;

public class three {
    public static String t2 = "am";
    public static String t3 = "aah";
    public static String t4 = "hello";
    public static String t5 = "hi";
    public static String t6 = "ooh";
    public static String t7 = "goodbye";
    public static String t8 = "bye-bye";
    public static String t9 = "are";
    public static String t10 = "good";
    public static String t11 = "morning";
    public static String t12 = "fine";
    public static String t13 = "thank";
    public static String t14 = "you";
    public static String t15 = "Ms";
    public static String t16 = "boy";
    public static String t17 = "girl";
    public static String t18 = "whoops";
    public static String t19 = "and";
    public static String t20 = "too";
    public static String t21 = "haha";
    public static String t22 = "what";
    public static String t23 = "is";
    public static String t24 = "your";
    public static String t25 = "name";
    public static String t26 = "please";
    public static String t27 = "afternoon";
    public static String t28 = "Mr";
    public static String t29 = "point";
    public static String t30 = "to";
    public static String t31 = "the";
    public static String t32 = "door";
    public static String t33 = "sit";
    public static String t34 = "down";
    public static String t35 = "stand";
    public static String t36 = "up";
    public static String t37 = "window";
    public static String t38 = "blackbord";
    public static String t39 = "bird";
    public static String t40 = "tweet";
    public static String t41 = "desk";
    public static String t42 = "chair";
    public static String t43 = "it";
    public static String t44 = "red";
    public static String t45 = "look";
    public static String t46 = "wow";
    public static String t47 = "yellow";
    public static String t48 = "blue";
    public static String t49 = "a";
    public static String t50 = "chameleon";
    public static String t51 = "my";
    public static String t52 = "panda";
    public static String t53 = "now";
    public static String t54 = "green";
    public static String t55 = "black";
    public static String t56 = "dog";
    public static String t57 = "cat";
    public static String t58 = "cap";
    public static String t59 = "one";
    public static String t60 = "two";
    public static String t61 = "three";
    public static String t62 = "four";
    public static String t63 = "five";
    public static String t64 = "six";
    public static String t65 = "seven";
    public static String t66 = "eight";
    public static String t67 = "nine";
    public static String t68 = "oh";
    public static String t69 = "ten";
    public static String t70 = "eleven";
    public static String t71 = "twelve";
    public static String t72 = "happy";
    public static String t73 = "birthday";
    public static String t74 = "here";
    public static String t75 = "present";
    public static String t76 = "this";
    public static String t77 = "pencil";
    public static String t78 = "pen";
    public static String t79 = "cake";
    public static String t80 = "old";
    public static String t81 = "yes";
}

我想随机一个1~81之间的数出来,每个数代表一个单词,然后输入单词,判断是否正确。
但是在随机时因为随机出来的是数字,而变量名都是以t开头的。
所以我要怎么办啊!

2条回答 默认 最新

相关推荐 更多相似问题