tailieunhanh - Lecture Java programming language: Conditional Control Structures - Ho Dac Hung

Lecture Java programming language: Conditional Control Structures introduces content such as the if Statement , the if-else statement, nested statements, the if-else if statement, the switch statement, generating random number, compound boolean expressions, the math class. | Conditional Control Structures Ho Dac Hung 1 The if Statement The if statement is a conditional control structure also called a decision structure which executes a set of statements when a condition is true. Conditional control structures are used to change program flow. The if statement takes the form if The if Statement The condition of an if statement is a boolean expression which evaluates to either true or false. Relational operators can be used to form boolean expression. 3 The if-else Statement The if statement can include an optional else clase that is executed when the if conditon evaluates to false. The if-else statement takes the following form if else 4 Nested Statements An if-else statement can contain another if-else or if statement. Statement placed within the same type of statememts are called nested. 5 The if-else if Statement The if-else if statement is used to decide among three or more actions and take the form if else if else 6 The switch Statement The switch statement is a conditional control structure that uses the result of an expression to determine which statements to execute. The switch statement takes the form switch case x break default 7 Generating Random Number Generating a series of random numbers is one of those common tasks that crops up from time to time. In Java it can be achieved simply by using the class. 8 Generating Random Number nextBoolean nextDouble nextFloat nextInt nextLong 9 Compound Boolean Expressions Conditions with complex criteria are formed using the amp amp and operators. How a compound boolean expression evaluates with amp amp and operators can be shown with truth tables. 10 The Math Class Java includes the Math class in the package for performing math functions. abs pow sqrt floor ceil sin cos tan 11

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.