if(1==1){ //checking if 1 is equal to one
System.out.println("one is equal to one"); //prints out the message if that is true
}
var num = 2; //creating a random variable (num) and assigning a value to it
if (num == 1){ //checking to see if that value of the variable is equal to one
System.out.println("num is equal to one"); //if num is equal to one we want to print it out
}
else{ //if the if statement is NOT true proceed with this
System.out.println("num is not equal to one"); // if the value does not equal to one we want to also print that out
}
var num = 15; //creating a random variable (num) and assigning a value to it
if(num < 10){ //checking to see if num is less than 10
System.out.println("num is less than 10"); //print result
}
else if(num > 10){ //checking to see if num is greater than 10
System.out.println("num is greater than 10"); //print result
}
else{ //If both of the previous statements are false then the number has to equal to 10
System.out.println("num is equal to 10"); //print result
}
int randomNum = (int)(Math.random() * 6); // random number between 0 to 5
if(randomNum == 0){ //Checking if the random number is 0
System.out.println("The number is: 0"); //printing out the random number if its 0
}
else if(randomNum == 1){ //Checking if the random number is 1
System.out.println("The number is: 1"); //printing out the random number if its 1
}
else if(randomNum == 2){ //Checking if the random number is 2
System.out.println("The number is: 2"); //printing out the random number if its 2
}
else if(randomNum == 3){ //Checking if the random number is 3
System.out.println("The number is: 3"); //printing out the random number if its 3
}
else if(randomNum == 4){ //Checking if the random number is 4
System.out.println("The number is: 4"); //printing out the random number if its 4
}
else{ //if everything else is false then the number is five
System.out.println("The number is: 5"); //printing out the random number if its 5
}
int randomNum = (int)(Math.random() * 6); // random number between 0 to 5
switch (randomNum) {
case 0: //Checks if randomNum is equal to zero
System.out.println("The number is: 0"); //printing out the random number if its 0
break; //stops the code
case 1: //Checks if randomNum is equal to one
System.out.println("The number is: 1"); //printing out the random number if its 1
break; //stops the code
case 2: //Checks if randomNum is equal to two
System.out.println("The number is: 2"); //printing out the random number if its 2
break; //stops the code
case 3: //Checks if randomNum is equal to three
System.out.println("The number is: 3"); //printing out the random number if its 3
break; //stops the code
case 4: //Checks if randomNum is equal to four
System.out.println("The number is: 4"); //printing out the random number if its 3
break; //stops the code
default: //If none of them are true then proceed
System.out.println("The number is: 5"); //printing out the random number if its 3
break; //stops the code
}
De Morgan's law
Description:
The complement of the union of the two sets A and B will be equal to the intersection of A' (complement of A) and B' (complement of B). In simpler terms, the opposite of a and b is equal to the opposite of a or the opposite of b. The opposite of a or b is equal to the opposite of a and the opposite of b.
var a = true; //creating a variable with a value of true
var b = false; //creating a variable with a value of false
if (!(a&b) == !a|!b){ // checks if De Morgan's law is correct
System.out.println("De Morgan's law is true"); //prints out the result
}
var a = true; //creating a variable with a value of true
var b = false; //creating a variable with a value of false
if (!(a|b) == !a&!b){ // checks if De Morgan's law is correct
System.out.println("De Morgan's law is true"); //prints out the result
}
var a = true; //creating a variable with a value of true
var b = false; //creating a variable with a value of false
if (!(a&b) == !a&!b){ // checks if De Morgan's law is correct
System.out.println("De Morgan's law is not true"); //prints out the result
}
else{ // if not true then proceed
System.out.println("De Morgan's law is true"); //prints out the result
}