There are two paths through this chart.
The "windshield wiper" decision is a two-way decision (sometimes called a "binary" decision.) It seems small, but in programs complicated decisions are made of many small decisions. Here is a program (suitable for "copy-paste-and-run") that includes a binary decision.
import java.io.*; class NumberTester { public static void main (String[] args) throws IOException { BufferedReader stdin = new BufferedReader ( new InputStreamReader( System.in ) ); String inData; int num; System.out.println("Enter an integer:"); inData = stdin.readLine(); num = Integer.parseInt( inData ); // convert inData to int if ( num < 0 ) // is num less than zero? System.out.println("The number " + num + " is negative"); // true-branch else System.out.println("The number " + num + " is positive"); // false-branch System.out.println("Good-bye for now"); // always executed } }
The words if
and else
are markers that divide
decision into two sections.
The else
is like a dividing line between the "true branch" and the
"false branch".
if
statement, and the two roads come together
just after the false-branch.