Boolean Truth Tables

In my Computer Science class, we are revisiting Boolean operators and are looking more in-depth at Boolean Truth Tables.

In this post, I will look at the Boolean operators of AND, OR, NAND, NOR, and XOR.

For clarification, the following are considered equal and will be used in the post:

a AND b > c is equal to a . b > c

a NAND b > c is equal to a . b > c

a OR b > c is equal to a + b > c

a NOR b > c is equal to a + b > c

a XOR b > c is equal to a ⊕ b > c

For additional clarification, here are the logic gate representations of each of the objects that are presented:

Boolean AND & NAND Logic Gates
Boolean AND & NAND Logic Gates
Boolean OR & NOR Logic Gates
Boolean OR & NOR Logic Gates
Boolean XOR & NOT Logic Gates
Boolean XOR & NOT Logic Gates

So, let’s build our truth tables for each of the above named scenarios:

a . b > c
A B Result
TRUE TRUE TRUE
TRUE FALSE FALSE
FALSE TRUE FALSE
FALSE FALSE FALSE

In this scenario, let’s say that a = 10, b = 5, and c = 7. In this case, the statement A > C is TRUE. However, the statement B > C is FALSE. If we look at the truth table above, the result is that the entire statement is now FALSE.

For an AND statement to be TRUE, all parts of the statement must be TRUE.

a + b > c
A B Result
TRUE TRUE TRUE
TRUE FALSE TRUE
FALSE TRUE TRUE
FALSE FALSE FALSE

In this scenario, let’s say that a = 10, b = 5, and c = 7. In this case, the statement A > C is TRUE. However, the statement B > C is FALSE. If we look at the truth table above, the result is that the entire statement is now TRUE.

For an OR statement to be TRUE, at least one part up to all parts of the statement must be TRUE.

a . b > c
A B Result
TRUE TRUE FALSE
TRUE FALSE TRUE
FALSE TRUE TRUE
FALSE FALSE TRUE

In this scenario, let’s say that a = 10, b = 5, and c = 7. In this case, the statement A > C is TRUE. However, the statement B > C is FALSE. If we look at the truth table above, the result is that the entire statement is now TRUE.

For a NAND statement to be TRUE, at least one part up to all parts of the statement must be FALSE.

a + b > c
A B Result
TRUE TRUE FALSE
TRUE FALSE FALSE
FALSE TRUE FALSE
FALSE FALSE TRUE

In this scenario, let’s say that a = 10, b = 5, and c = 7. In this case, the statement A > C is TRUE. However, the statement B > C is FALSE. If we look at the truth table above, the result is that the entire statement is now FALSE.

For a NOR statement to be TRUE, all parts of the statement must be FALSE.

a ⊕ b > c
A B Result
TRUE TRUE FALSE
TRUE FALSE TRUE
FALSE TRUE TRUE
FALSE FALSE FALSE

In this scenario, let’s say that a = 10, b = 5, and c = 7. In this case, the statement A > C is TRUE. However, the statement B > C is FALSE. If we look at the truth table above, the result is that the entire statement is now TRUE.

For a XOR statement to be TRUE, at least one condition in the statement must be TRUE. However, if all conditions in the statement are TRUE, then the result is FALSE.

Launch Angle, Velocity, Range, and Height

In my Principles of Technology class, we are preparing for a water balloon launching project. Teams have to build a rig to launch a water balloon at a target.

The targets are placed at fixed intervals of 20 yards, 40 yards, and 50 yards from the launchers. At each target site will be either a school administrator or myself.

Before launching, each team must present their mathematical proofs of concept of how they ensure they hit their target(s).

Leading up to several days of building, we are taking a test over these calculations.

Launch Angle Calculator

Launch Angle Exam Review Guide

Launch Angle Exam Review Guide Answers

As several of my students have not yet covered Trigonometric mathematics, I have provided a quick “plug-and-chug” worksheet in Excel that solves for the missing equations.

It will solve for the following:

  • H when given Vo and Theta
    • =((((B2)^2)*((SIN(B4))^2)))/(2*B5)
  • R when given Vo and Theta
    • =((((C2)^2)*((SIN(2*C4)))))/(B5)
  • Vo when given H and Theta
    • =SQRT((D6*(2*D5))/((SIN(D4))^2))
  • Vo when given R and Theta
    • =SQRT((E7*E5)/(SIN(2*E4)))
  • Theta when given Vo and H
    • =ASIN(SQRT((F6*(2*F5))/((F2)^2)))
  • Theta when given Vo and R
    • =ASIN((G7*G5)/((G2)^2))/2

2-Dimensional Arrays in Java

Today, we started to cover 2-dimensional arrays in Java. I decided to start with something very easy:

2-D Array Visual
2-D Array Visual

We have an array with 2 rows and 3 columns. Like all things in Java, we start counting our indices at 0.

As such, the value of [0][0] is Vanilla and [1][0] is Ice Cream. Note that the first number in the reference points to the row and the second number in the reference points to the column.

import java.util.*;
public class TwoDArrays {
    public static void main(String[] args){
        String[][] myBigArray = new String [][] {
            {"Vanilla ", "Chocolate ", "Strawberry "},
            {"Ice Cream", "Cookie", "Candy"}
        };
        System.out.println(myBigArray[0][0] + myBigArray[1][0]);
        System.out.println(myBigArray[0][1] + myBigArray[1][0]);
        System.out.println(myBigArray[0][2] + myBigArray[1][0]);
        
        System.out.println(myBigArray[0][0] + myBigArray[1][1]);
        System.out.println(myBigArray[0][1] + myBigArray[1][1]);
        System.out.println(myBigArray[0][2] + myBigArray[1][1]);
        
        System.out.println(myBigArray[0][0] + myBigArray[1][2]);
        System.out.println(myBigArray[0][1] + myBigArray[1][2]);
        System.out.println(myBigArray[0][2] + myBigArray[1][2]);
    }
}

Line 4 is where we created the 2-dimensional array named “myBigArray”.

Lines 5 and 6 are where we populated the array. Note that line 5 is the first row and line 6 is the second row.

Lines 8 through 18 are where we are outputting text that is “fed” by the 2-D array.

Line 8 concatenates [0][0] with [1][0] which is Vanilla and Ice Cream.

Line 9 concatenates [0][1] with [1][0] which is Chocolate and Ice Cream.

Line 10 concatenates [0][2] with [1][0] which is Strawberry and Ice Cream.

Line 12 concatenates [0][0] with [1][1] which is Vanilla and Cookie.

Line 13 concatenates [0][1] with [1][1] which is Chocolate and Cookie.

Line 14 concatenates [0][2] with [1][1] which is Strawberry and Cookie.

Line 16 concatenates [0][0] with [1][2] which is Vanilla and Candy.

Line 17 concatenates [0][1] with [1][2] which is Chocolate and Candy.

Line 18 concatenates [0][2] with [1][2] which is Strawberry and Candy.