Try This 2-2 Display a Truth Table for the Logical Operators

LogicalOpTable.java

In this project, you will create a program that displays the truth table for Java’s logical operators. You must make the columns in the table line up. This project makes use of several features covered in this chapter, including one of Java’s escape sequences and the logical operators. It also illustrates the differences in the precedence between the arithmetic + operator and the logical operators.

1. Create a new file called LogicalOpTable.java.

2. To ensure that the columns line up, you will use the \t escape sequence to embed tabs into each output string. For example, this println( ) statement displays the header for the table:

3. Each subsequent line in the ...

Get Java, A Beginner's Guide, 5th Edition, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.