Given the following declarations, write a Boolean expressionfor each of the prob
ID: 3614172 • Letter: G
Question
- Given the following declarations, write a Boolean expressionfor each of the problems listed below.
boolean x, y, z;
int i, j, k;- Write a Boolean expression that is true if and only if either xor y is true but not both
- Write a Boolean expression that is true if and only if x istrue and y is false
- Write a Boolean expression that is true if and only if i has avalue between -3 and 7 (excluding -3 and 7)
- Write a Boolean expression that is true if and only if i is anodd number
- Write a Boolean expression that is true if and only if the sumof i and j is equal to twice the value of k
- Write a Boolean expression that is true if and only if i, j,and k all have distinct values
- For each of the following program segments, write the outputproduced.
-
int x = 12, y = -7, z = 0, a;
if (x > y) {
if (x > z) {
a = x;
}
else {
a = z;
}
}
else {
if (y > z) {
a = y;
}
else {
a = z;
}
}
System.out.println(a); -
int number = 45;
if (number < 10) {
System.out.println("what");
}
else if (number < 50) {
System.out.println("will");
}
else if (number < 100) {
System.out.println("this");
}
else {
System.out.println("print");
} -
int x = 12, y = -7, z = 0;
if (x > y) {
int t = x;
x = y;
y = t;
}
if (x > z) {
int t = x;
x = z;
z = t;
}
if (y > z) {
int t = y;
y = z;
z = t;
}
System.out.println(x + "," + y + "," + z);
-