有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

带有文件字符串的java建议

我正在尝试读取外部文件。我已经成功地读取了文件,但现在我有一个小问题。该文件包含大约88个动词。该文件中的动词如下所示: 曾经 跳动 变成变成 等等

我现在需要帮助的是,我想要一个类似于测验的程序,其中只有两个来自动词的随机字符串出现,用户必须填充缺少的字符串。我想要这个(“----”),而不是丢失的那个。我的英语不是很好,所以我希望你明白我的意思

    System.out.println("Welcome to the programe which will test you in english verbs!");
    System.out.println("You can choose to be tested in up to 88.");
    System.out.println("In the end of the programe you will get a percentage of total right answers.");

    Scanner in = new Scanner(System.in);
    System.out.println("Do you want to try??yes/no");

    String a = in.nextLine();
    if (a.equals("yes")) {
        System.out.println("Please enter the name of the file you want to choose: ");

    } else {
        System.out.println("Programe is ended!");
    }



    String b = in.nextLine();
    while(!b.equals("verb.txt")){
        System.out.println("You entered wrong name, please try again!");
         b = in.nextLine();

    }
    System.out.println("How many verbs do you want to be tested in?: ");
    int totalVerb = in.nextInt();
    in.nextLine();


    String filename = "verb.txt";
    File textFile = new File(filename);
    Scanner input = new Scanner(textFile);

    for (int i = 1; i <= totalVerb; i++){



        String line = input.nextLine();

        System.out.println(line);
        System.out.println("Please fill inn the missing verb: ");
        in.next();
    }

    System.out.println("Please enter your name: ");
    in.next();

共 (0) 个答案