In this appendix, we discuss the theory and principles of structured programming. The concepts presented here are crucial in building classes and manipulating objects. We introduce Java’s compound assignment, increment and decrement operators, and we discuss the portability of Java’s primitive types. We demonstrate Java’s for
, do
...while
and switch
statements. Through a series of short examples using while
and for
, we explore the essentials of counter-controlled repetition. We create a version of class GradeBook
that uses a switch
statement to count the number of A, B, C, D and F grade equivalents in a set of numeric grades entered by the user. We introduce the break
and continue
program-control statements. We discuss Java’s logical operators, which enable you to use more complex conditional expressions in control statements.