我正在尝试使用循环创建一个聊天机器人,该循环将与用户进行对话,并在用户键入“再见”时停止。有点像我在这里尝试做的事情,除了我不擅长编程:
Scanner sc = new Scanner (System.in);
String question;
System.out.println("Hello");
do
{
question = sc.nextLine();
if (question.equals("how are you");
{
System.out.println("good");
}
if (question.equals("bye"))
{
System.out.println("bye");
break;
}
} while (!sc.nextLine().equals("bye"));
}
}