O'Reilly logo

Android™ How to Program, Second Edition by Abbey Deitel, Harvey Deitel, Paul Deitel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

C.18. switch Multiple-Selection Statement

Sections C.5C.6 discussed the if single-selection and the if...else double-selection statements. The switch multiple-selection statement performs different actions based on the possible values of a constant integral expression of type byte, short, int or char.

GradeBook Class with switch Statement to Count A, B, C, D and F Grades

Figure C.17 enhances the GradeBook case study that we began presenting in Appendix B. The new version we now present not only calculates the average of a set of numeric grades entered by the user, but uses a switch statement to determine whether each grade is the equivalent of an A, B, C, D or F and to increment the appropriate grade counter. The class also displays a summary ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required