求用java编写 假设x=10,y=20,z=30,求下列布尔表达式的值(1) x<10 || x<10
假设x=10,y=20,z=30,求下列布尔表达式的值(1)x<10||x<10(2)x>y&&y>x(3)(x<y+z)&&(x+10<=20)(4)z-y==x&&(...
假设x=10,y=20,z=30,求下列布尔表达式的值
(1) x<10 || x<10
(2) x>y && y>x
(3) (x<y+z) && (x+10<=20)
(4) z-y==x && (y-z)==x
(5) x<10 && y>x
(6) x>y || y>x
(7) !(x<y+z) || !(x+10<=20)
(8) ( !(x==y)) && (x !=y) && (x<y || y<x)
请帮忙编写一下代码谢谢 展开
(1) x<10 || x<10
(2) x>y && y>x
(3) (x<y+z) && (x+10<=20)
(4) z-y==x && (y-z)==x
(5) x<10 && y>x
(6) x>y || y>x
(7) !(x<y+z) || !(x+10<=20)
(8) ( !(x==y)) && (x !=y) && (x<y || y<x)
请帮忙编写一下代码谢谢 展开
2个回答
展开全部
package test;
public class Test{
public static void main(String[] args) {
int x=10,y=20,z=30;
boolean a=x<10 || x<10 ;
boolean b=x>y && y>x;
boolean c=(x<y+z)&&(x+10<=20);
boolean d=z-y==x&&(y-z)==x;
boolean e=x<10&&y>x;
boolean f=x>y||y>x;
boolean g=!(x<y+z)||!(x+10<=20);
boolean h=(!(x==y))&&(x!=y)&&(x<y || y<x);
System.out.println(a);
System.out.println(b);
System.out.println(c);
System.out.println(d);
System.out.println(e);
System.out.println(f);
System.out.println(g);
System.out.println(h);
}
}
结果:
false
false
true
false
false
true
false
true
public class Test{
public static void main(String[] args) {
int x=10,y=20,z=30;
boolean a=x<10 || x<10 ;
boolean b=x>y && y>x;
boolean c=(x<y+z)&&(x+10<=20);
boolean d=z-y==x&&(y-z)==x;
boolean e=x<10&&y>x;
boolean f=x>y||y>x;
boolean g=!(x<y+z)||!(x+10<=20);
boolean h=(!(x==y))&&(x!=y)&&(x<y || y<x);
System.out.println(a);
System.out.println(b);
System.out.println(c);
System.out.println(d);
System.out.println(e);
System.out.println(f);
System.out.println(g);
System.out.println(h);
}
}
结果:
false
false
true
false
false
true
false
true
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询