05-ControlStructures1

05-ControlStructures1 - Chapter V Control Structures I...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: Chapter V Control Structures I Chapter V Topics 5.1 Introduction 5.2 Types of Control Structures 5.3 Relational Operators 5.4 Keyboard Input 5.5 One-Way Selection 5.6 Two-Way Selection 5.7 Multiple-Way Selection 5.8 Fixed Repetition 5.9 Conditional Repetition 5.10 Control Structures and Graphics 5.11 Worked Out Exercises 5.12 Summary Chapter V Control Structures I Page 177 5.1 Introduction The previous chapter focused on using methods and parameters , which are an integral part of Object Oriented Programming . The intention in Exposure Java is to present OOP in stages. A thorough understanding of Object Oriented Programming is vital in modern computer science. At the same time, you also need to learn the syntax of a programming language. You cannot write proper Java OOP programs unless you know the Java sentence structure or syntax. A prerequisite for a creative writing course is knowledge of grammar. Frequently, it is mentioned that programming language syntax is trivial. The essence of programming is design, data structures and algorithms. This is very true, and very lovely, but language syntax tends to be trivial only if you know syntax. You will get very frustrated with your programs when they do not compile because of syntax problems. In an earlier chapter I mentioned that program execution follows the exact sequence of program statements. That was true, but also a rather incomplete explanation. There is a lot more to the program flow picture. We can expand on the exact program sequence by stating that program flow follows the sequence of program statements, unless directed otherwise by a Java control structure. Program Flow Program Flow follows the exact sequence of listed program statements, unless directed otherwise by a Java control structure. Programs in any computer language require control structures. It may appear that all our program examples were written without the use of any control structures, but the control was subtle. As mentioned earlier, control was provided by a sequence of program statements. That type of control is called simple sequence . Simple sequence alone is not very satisfactory for programs of any type of consequence. Programs constantly make decisions. A payroll program needs to change the amount paid, if the hours exceed 40 per week. The same payroll program can have many variations of tax deductions based on the number of dependents claimed. A payroll program also needs to have the ability to repeat the same actions for additional employees. In other words, a program needs to Page 178 Exposure Java 2009, APCS Edition 08-08-09 have the ability to repeat itself, or repeat certain program segments. The language features that allow that type of control will be introduced in this chapter....
View Full Document

Page1 / 64

05-ControlStructures1 - Chapter V Control Structures I...

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