public static boolean and(boolean b0, boolean b1) { // add code here } public static boolean or(boolean b0, boolean b1) { // add code here } public static boolean xor(boolean b0, boolean b1) { // add code here } public static boolean nand(boolean b0, boolean b1) { // add code here } public static boolean nor(boolean b0, boolean b1) { // add code here } public static boolean special(boolean b0, boolean b1) { // add code here } public static void printHeader(String logicalOperatorName) { // add code here } public static void printRow(boolean b0, boolean b1, boolean result) { // add code here }
// Print truth table (AND) printHeader("AND"); printRow(true, true, and(true,true)); printRow(true, false, and(true,false)); printRow(false, true, and(false,true)); printRow(false, false, and(false,false)); // add code to test the other methods
(b0 XOR b1) AND (NOT(b0) OR b1)
b0 b1 b0 AND b1
The value of b0 followed by a tab, then the value of b1 followed by a tab, then the value of result.
Done correctly, the output should similar to this:true false false
Test your completed methods by using calling them inside the main() curly braces. In the code that was provided, you have a full example of printing a correct truth table for the AND method.
When you are satisfied that your all methods work correctly, submit your R6.java program using the Checkin tab on the course website.
In order to receive full credit for this recitation, all methods(and(), or(), nand(), xor(), nor(), special(), printHeader(), and printRow()) must work as specified. We will not be evaluating code you write inside your main().
You must submit your R6.java program using the Checkin tab on the course website, and automated testing will be enabled.