tailieunhanh - Lecture note Java methods A & AB: Object-oriented programming and data structures: Chapter 7 - Maria Litvin, Gary Litvin

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 Java Methods A & AB Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin Copyright © 2006 by Maria Litvin, Gary Litvin, and Skylight Publishing. All rights reserved. if (chapter == 7) 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 | Boolean Expressions and if-else Statements Java Methods A & AB Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin Copyright © 2006 by Maria Litvin, Gary Litvin, and Skylight Publishing. All rights reserved. if (chapter == 7) 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 variable. Similarly, you

TÀI LIỆU LIÊN QUAN
crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.