Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
After you have read and studied this chapter, you should be able to: Implement selection control in a program by using if statements, implement selection control in a program by using switch statements, write boolean expressions with relational and boolean operators,. | Chapter 5 Selection Statements Chapter 5 Objectives After you have read and studied this chapter, you should be able to Implement selection control in a program by using if statements. Implement selection control in a program by using switch statements. Write boolean expressions with relational and boolean operators. Evaluate given boolean expressions correctly. ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 5 Objectives, cont. After you have read and studied this chapter, you should be able to Nest an if statement inside another if statement’s then or else part correctly. Describe how objects are compared. Choose the appropriate selection control statement for a given task. ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. 5.1 The if Statement Statements in programs are executed in sequence. We can add decision-making statements to a program to alter the control flow. The statement that alters the control flow is called a control statement. ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. 5.1 The if Statement The if statement is one type of selection statement. InputHandler input = new InputHandler(); int testScore = input.getInteger(“Enter test score:”); if (testScore ) else ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. 5.1 The if Statement The is a conditional expression that is evaluated to either true or false. ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Fig. 5.1 . | Chapter 5 Selection Statements Chapter 5 Objectives After you have read and studied this chapter, you should be able to Implement selection control in a program by using if statements. Implement selection control in a program by using switch statements. Write boolean expressions with relational and boolean operators. Evaluate given boolean expressions correctly. ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 5 Objectives, cont. After you have read and studied this chapter, you should be able to Nest an if statement inside another if statement’s then or else part correctly. Describe how objects are compared. Choose the appropriate selection control statement for a given task. ©TheMcGraw-Hill Companies, Inc. Permission required for reproduction or display. 5.1 The if Statement Statements in programs are executed in sequence. We can add decision-making statements to a program to alter the control flow. The statement that alters the control flow .