tailieunhanh - Chapter 5 Conditionals and Loops
In computer programming, conditional loops or repetitive control structures are a way for computer programs to repeat one or more various steps depending on conditions set either by the programmer initially or real-time by the actual program. | Chapter 5 Conditionals and Loops © 2004 Pearson Addison-Wesley. All rights reserved 5- Conditionals and Loops Now we will examine programming statements that allow us to: make decisions repeat processing steps in a loop Chapter 5 focuses on: boolean expressions conditional statements comparing data repetition statements iterators © 2004 Pearson Addison-Wesley. All rights reserved 5- Outline The if Statement and Conditions Other Conditional Statements Comparing Data The while Statement Iterators Other Repetition Statements © 2004 Pearson Addison-Wesley. All rights reserved 5- Flow of Control Unless specified otherwise, the order of statement execution through a method is linear: one statement after another in sequence Some programming statements allow us to: decide whether or not to execute a particular statement execute a statement over and over, repetitively These decisions are based on boolean expressions (or conditions) that evaluate to true or false The order of . | Chapter 5 Conditionals and Loops © 2004 Pearson Addison-Wesley. All rights reserved 5- Conditionals and Loops Now we will examine programming statements that allow us to: make decisions repeat processing steps in a loop Chapter 5 focuses on: boolean expressions conditional statements comparing data repetition statements iterators © 2004 Pearson Addison-Wesley. All rights reserved 5- Outline The if Statement and Conditions Other Conditional Statements Comparing Data The while Statement Iterators Other Repetition Statements © 2004 Pearson Addison-Wesley. All rights reserved 5- Flow of Control Unless specified otherwise, the order of statement execution through a method is linear: one statement after another in sequence Some programming statements allow us to: decide whether or not to execute a particular statement execute a statement over and over, repetitively These decisions are based on boolean expressions (or conditions) that evaluate to true or false The order of statement execution is called the flow of control © 2004 Pearson Addison-Wesley. All rights reserved 5- Conditional Statements A conditional statement lets us choose which statement will be executed next Therefore they are sometimes called selection statements Conditional statements give us the power to make basic decisions The Java conditional statements are the: if statement if-else statement switch statement © 2004 Pearson Addison-Wesley. All rights reserved 5- The if Statement The if statement has the following syntax: if ( condition ) statement; if is a Java reserved word The condition must be a boolean expression. It must evaluate to either true or false. If the condition is true, the statement is executed. If it is false, the statement is skipped. © 2004 Pearson Addison-Wesley. All rights reserved 5- Logic of an if statement condition evaluated statement true false © 2004 Pearson Addison-Wesley. All rights reserved 5- Boolean Expressions A condition often uses one of .
đang nạp các trang xem trước