ch05 - Java Programming Fourth Edition Chapter 5 Making...

Info iconThis preview shows pages 1–13. 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

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

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: Java Programming Fourth Edition Chapter 5 Making Decisions Java Programming, Fourth Edition 2 Objectives Understand decision making Make decisions with the if and if...else structures Use multiple statements in an if or if...else structure Nest if and if...else statements Use AND and OR operators Java Programming, Fourth Edition 3 Objectives (continued) Learn to avoid common errors when making decisions Use the switch statement Use the conditional and NOT operators Understand precedence Java Programming, Fourth Edition 4 Understanding Decision Making Pseudocode Use paper and pencil Plan programs logic By writing plain English statements Accomplish important steps in a given task Use everyday language Flowchart Steps in diagram form Series of shapes connected by arrows Java Programming, Fourth Edition 5 Understanding Decision Making (continued) Flowchart (continued) Programmers use variety of shapes to represent different tasks Rectangle to represent any unconditional step Diamond to represent any decision Sequence structure One step follows another unconditionally Cant branch away or skip a step Java Programming, Fourth Edition 6 Flowchart and Pseudocode of a Series of Sequential Steps Java Programming, Fourth Edition 7 Understanding Decision Making (continued) Decision structure Involves choosing between alternative courses of action Based on some value within program All computer decisions are yes-or-no decisions Boolean values Values true and false Used in every computer decision Java Programming, Fourth Edition 8 Flowchart Including a Decision Java Programming, Fourth Edition 9 Making Decisions with the if and if...else Structures if statement Simplest statement to make decision Boolean expression appears within parentheses Space between keyword if and opening parentheses Statement ends if it evaluates as true Execution always continues to next independent statement Use double equal sign to determine equivalency Java Programming, Fourth Edition 10 Making Decisions with the if and if...else Structures (continued) if statement (continued) Use Boolean expression in parentheses Or store Boolean expressions value in a Boolean variable If statement similar to English-language statement Java Programming, Fourth Edition 11 Decision Structure Illustrating an if Statement Java Programming, Fourth Edition 12 The if...else Structure Single-alternative if Only perform action, or not Based on one alternative Dual-alternative if Two possible courses of action if...else statement Performs one action when Boolean expression evaluates true Performs different action when Boolean expression evaluates false Java Programming, Fourth Edition...
View Full Document

Page1 / 42

ch05 - Java Programming Fourth Edition Chapter 5 Making...

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

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