11-ControlStructures2

11-ControlStructures2 - Chapter XI Control Structures II...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter XI Control Structures II Chapter XI Topics 11.1 Introduction 11.2 Brief Review of Control Structures 11.3 Which is the Best Loop to Use? 11.4 Nested Selection 11.5 Nested Looping 11.6 Compound Conditions 11.7 Program Input Protection 11.8 Short-Circuiting Conditions 11.9 Recursion, a Sneak Preview 11.10 Worked-Out Exercises 11.11 Summary Chapter XI Control Structures II 535
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
11.1 Introduction You knew that this chapter was coming. Anytime that a chapter is titled Control Structures I , there is guaranteed to be a sequel. Hopefully, the Boolean chapter has given you some tools that can be applied in this chapter. Frankly, the Boolean chapter by itself is difficult to justify. But in the area of complex control structures, knowledge of Boolean logic is very useful. This chapter introduces a variety of advanced control structure features. We start by looking at some specialized features of the for loop structure. The next concern is to see how control structures can be nested inside each other. Then comes the compound condition section which draws heavily on the previous Boolean logic chapter. The chapter then concludes with some practical input protection program examples that also require understanding of Boolean logic and a brief section on short-circuiting compound decisions. When you are finished with this chapter, you will be able to start writing some rather complex programs that are both challenging and interesting. Simple sequence programs, and even programs with simple conditions, lack the flexibility that you can create with the Java programming tools shown in this chapter. The assignment for this chapter will be a very practical assignment that involves computing interest for loan payment, amortization schedules and credit card payoffs. It is a large assignment that will utilize many different control structures. 11.2 Brief Review of Control Structures Program Java1101.java , in figure 11.1, reviews selection control structures. You see examples of one-way selection with if , two-way selection with if…else , and multi-way selection with switch . 536 Exposure Java 2009, APCS Edition 08-08-09
Background image of page 2
Figure 11.1 // Java1101.java // This program reviews selection structures. import java.util.Scanner; public class Java1101 { public static void main (String args[]) { System.out.println("\nJAVA1101.JAVA\n"); Scanner input = new Scanner(System.in); System.out.print("Enter a number ===>> "); int number = input.nextInt(); S y s t e m . o u t . p r i n t l n (
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/14/2010 for the course APSC AP taught by Professor Kurt during the Spring '98 term at Wooster.

Page1 / 56

11-ControlStructures2 - Chapter XI Control Structures II...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online