In this chapter, we introduce several of C#’s remaining control statements. (The
foreach statement is introduced in Chapter 8.) The control statements we study here and in Chapter 5 are helpful in building and manipulating objects.
Through a series of short examples using
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
continue program-control statements. We discuss C#’s logical operators, which enable you to use more complex conditional expressions in control statements. Finally, we summarize C#’s control ...