import java.util.Random;
import java.util.Scanner;
public class Boolean {
public static void main(String[] args){
String zz;
Scanner keyboard = new Scanner(System.in);
Random r1 = new Random();
Random r2 = new Random();
Random greatless = new Random();
int x = r1.nextInt(10) + 1;
int y = r2.nextInt(10) + 1;
int z = greatless.nextInt(2) + 1;
if (z == 2)
{
zz = "<";
}
else
{
zz = ">";
}
System.out.println("Is " + x + " " + zz + " " + y + "? (y/n)");
String ans = keyboard.nextLine();
}
}
我不知道键盘输入后该写什么。我想通过使用布尔类来告诉他们是对还是错......所以我想要一个 if else 之后。我想像...
if (ans.equalsIgnoreCase("y")
{
-insert code-
}
else
{
- insert code-
}