-5
我想写一个程序,它应该给我R3
作为输出。我的代码是在这里:如何用println获得输出()
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
boolean P;
boolean Q;
System.out.println("please enter 2 number P and Q");
System.out.print('\n');
P = console.nextBoolean();
Q = console.nextBoolean();
boolean R1;
boolean R2;
boolean R3;
R1 = (P & Q);
R2 = (Q == R1);
R3 = (P == R2);
System.out.print("the output is");
System.out.println(R3);
}
}
我搜索了很多,但我不知道为什么这段代码不起作用。此代码运行,但是当我输入P
和Q
时,我看不到任何输出。你能帮我吗?
那么,你怎么进入,当你运行的程序?告诉我们您在键盘上输入的按键顺序。同时告诉我们为什么你要求用户输入数字,因为你只能读取布尔值。 – 2015-03-31 18:21:39
如果在出现提示时输入“true”和“false”,则此功能起作用。如果您按提示输入数字,则会引发异常。 – 2015-03-31 18:23:47
你如何运行程序?找不到任何错误。 – Bubletan 2015-03-31 18:24:23