Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Chapter 7 - Boolean expressions and if-else statements. This chapter also includes relational and logical operators, De Morgan’s Laws, the switch statement and enum data types. Another objective is to discuss team development and illustrate software reusability in the context of a simple but realistic case study, the Craps project. | Boolean Expressions and if-else Statements if (chapter == 7) Copyright © 2011 by Maria Litvin, Gary Litvin, and Skylight Publishing. All rights reserved. Java Methods Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin 2nd AP edition with GridWorld 7- This chapter also includes relational and logical operators, De Morgan’s Laws, the switch statement and enum data types. Objectives: Learn about the boolean data type Learn the syntax for if-else statements Learn about relational and logical operators, De Morgan’s laws, short-circuit evaluation Learn when to use nested if-else statements, if-else-if sequences, the switch statement Learn about enum data types 7- Another objective is to discuss team development and illustrate software reusability in the context of a simple but realistic case study, the Craps project. if-else Statement if ( ) { } else { } if ( ) { } else clause is . | Boolean Expressions and if-else Statements if (chapter == 7) Copyright © 2011 by Maria Litvin, Gary Litvin, and Skylight Publishing. All rights reserved. Java Methods Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin 2nd AP edition with GridWorld 7- This chapter also includes relational and logical operators, De Morgan’s Laws, the switch statement and enum data types. Objectives: Learn about the boolean data type Learn the syntax for if-else statements Learn about relational and logical operators, De Morgan’s laws, short-circuit evaluation Learn when to use nested if-else statements, if-else-if sequences, the switch statement Learn about enum data types 7- Another objective is to discuss team development and illustrate software reusability in the context of a simple but realistic case study, the Craps project. if-else Statement if ( ) { } else { } if ( ) { } else clause is optional 7- When the if or else clause contains only one statement, the braces are optional, but it is safer to always keep them. With braces it is also easier to add a statement to an if or else clause. boolean Data Type George Boole (1815 - 1864) boolean variables may have only two values, true or false. You define boolean fields or boolean local variables the same way as other variables. boolean true false Reserved words private boolean hasMiddleName; boolean isRolling = false; 7- There is no point, really, in using boolean symbolic constants because you can just use true and false in the code. George Boole was a British mathematician who studied properties of formal logic. Boolean Expressions In if ( ) is a Boolean expression. A Boolean expression evaluates to either true or false. Boolean expressions are written using boolean variables and relational and logical operators. 7- You can assign the result of an arithmetic expression to an int or double