admin 管理员组

文章数量: 887021


2024年1月11日发(作者:replace等于)

用Java写一个在线考试系统的代码

```

//Java Online Exam System

import .*;

public class OnlineExam {

public static void main(String[] args) {

//Define array for questions and answers

String[] questions = {"What is the capital of France?",

"What is the capital of Spain?",

"What is the capital of Germany?"};

String[] answers = {"Paris", "Madrid", "Berlin"};

//Welcome message

n("Welcome to the Online Exam System!");

//Start the exam

Scanner scanner = new Scanner();

n("Let's start the exam");

//Loop through each question

int numCorrect = 0;

for (int i = 0; i < ; i++) {

n(questions[i]);

String answer = ne();

if ((answers[i])) {

numCorrect++;

}

}

//Print results

n("You got " + numCorrect + " out of " +

+ " correct!");

}

}

```


本文标签: 考试 等于 系统 作者 代码