Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Given the following declarations, write a Boolean expressionfor each of the prob

ID: 3614172 • Letter: G

Question

  1. Given the following declarations, write a Boolean expressionfor each of the problems listed below.
     boolean x, y, z;
    int i, j, k;
    1. Write a Boolean expression that is true if and only if either xor y is true but not both
    2. Write a Boolean expression that is true if and only if x istrue and y is false
    3. Write a Boolean expression that is true if and only if i has avalue between -3 and 7 (excluding -3 and 7)
    4. Write a Boolean expression that is true if and only if i is anodd number
    5. Write a Boolean expression that is true if and only if the sumof i and j is equal to twice the value of k
    6. Write a Boolean expression that is true if and only if i, j,and k all have distinct values
  2. For each of the following program segments, write the outputproduced.
    1.  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);
    2.  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");
      }
    3.  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);

Explanation / Answer

int x = 12, y = -7, z = 0, a;if (x > y) { //12>-7if (x > z) { //12>0a = 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) { //number = 45 y) { //12>-7int t = x; //t=12x = y; //x = -7y = t; // y=12}if (x > z) { // 12>0int t = x; //t=12x = z; //x =0z = t; // z = 12}if (y > z) { // int t = y;y = z;z = t;}System.out.println(x + "," + y + "," + z); // Write a Boolean expression that is true if and only if either x or y is true but not both : iff(x==true || y == true); Write a Boolean expression that is true if and only if x is true and y is false : iff(x == true&& y==false) Write a Boolean expression that is true if and only if i has a value between -3 and 7 (excluding -3 and 7):iff(i>=-3 && i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote