Exercise 1: Computing an Expression using Logic

In this exercise, you are required to implement the logical operators such as not, xor, boolean and, boolean NOT to compute the result

We'll cover the following

Problem Statement

There’s always some logic in whatever we do, whether it seems like that or not. This time, we are going to give you the logic and all you need to do is implement it. The challenge is to create the expression explained below and find what result it gives!

Coding Exercise

The first step is done for you, which is the method. The method takes in two variables and computes a logical expression using them. For explanation’s sake, the parameters are called x and y.

Now you must do the following:

  • Find the Boolean NOT of x
  • Boolean XOR this with x itself
  • Find the Boolean AND of this answer with y
  • Return the Boolean NOT of the entire expression

Only write the code where instructed in the snippet below. The return statement and the variable to be returned are already mentioned for you.

Important Note: Since we are returning true by default in the code below when you run the code without writing the solution it will still pass two of our test cases. However, your code needs to pass ALL four of our test cases in order to be considered correct.

Good Luck!

Get hands-on with 1200+ tech skills courses.