How to code simple control statements

Relational operations:

  • == Equality
  • != Inequality
  • > Greater than
  • < Less than
  • >= Greater than or equal
  • <= Less than or equal

Examples:

  • discountPercent == 2.3
  • subtotal != 0
  • i < months

Two methods of the String class

  • equals(String)
  • equalsIgnoreCase(String)

Examples:

  • userEntry.equals("Y");
  • userEntry.equalsIgnoreCase("Y");
How to use if/else:
if (bolleanExpression) {statements}
else {statements}
How to use for:
for (int i=0;i<10;i++;)
{statements}
How to use while:
while (i < 5)
{statements}
How to use do:
do
{statements}
while (i < 5)