tailieunhanh - Lecture Java methods: Object-oriented programming and data structures (3rd AP edition): Chapter 6 - Maria Litvin, Gary Litvin
Chapter 6 - Data types, variables, and arithmetic. In this chapter, the learning objectives are: Discuss primitive data types; learn how to declare fields and local variables; learn about arithmetic operators, compound assignment operators, and increment/decrement operators; discuss common mistakes in arithmetic. | Boolean Expressions and if-else Statements if (chapter == 6) Copyright © 2015 by Maria Litvin, Gary Litvin, and Skylight Publishing. All rights reserved. Java Methods Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin 3rd AP edition 6- 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 6- 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 6- When | Boolean Expressions and if-else Statements if (chapter == 6) Copyright © 2015 by Maria Litvin, Gary Litvin, and Skylight Publishing. All rights reserved. Java Methods Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin 3rd AP edition 6- 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 6- 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 6- 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; 6- George Boole was a British mathematician who studied properties of formal logic. There is no point, really, in using boolean symbolic constants because you can just use true and false in the code. 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. 6- You can assign the result of an arithmetic expression to an int or double variable. .
đang nạp các trang xem trước