Truth Tables and De Morgan's Rules

Read this chapter, which discusses Boolean variables as used in decision tables. Truth tables are used to collect variables and their values relative to decisions that have to be made within control structures.

10. Equivalent Statements

Answer:Usually there are many equivalent ways to write an if statement.

Equivalent Statements

Here is the original fragment, which uses AND:

if (  !(speed > 2000 && memory > 512)  )  System.out.println("Reject this computer");else  System.out.println("Acceptable computer");

Here is an equivalent fragment that uses OR:

if (  speed <= 2000  ||  memory <= 512 )  System.out.println("Reject this computer");else  System.out.println("Acceptable computer");

Yet another equivalent fragment reverses the order of the true and false branches of the statement.

if (  speed > 2000  &&  memory > 512 )  System.out.println("Acceptable computer");else  System.out.println("Reject this computer");

The last fragment is probably the best choice because it is the easiest to read. It follows the pattern:

if ( expression that returns "true" for the desired condition )  perform the desired actionelse  perform some other action

Generally, people find statements that involve NOT to be confusing. Avoid using using NOT, if you can. If NOTs are needed, try to apply them to small subexpressions, only.

Question 10:Rewrite the following natural language statement into an equivalent easily understood statement.Not always are robins not seen when the weather is not fair.