Lecture Java programming language: Conditional Control Structures - Ho Dac Hung
Số trang: 11
Loại file: pdf
Dung lượng: 139.73 KB
Lượt xem: 6
Lượt tải: 0
Xem trước 2 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
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.
Nội dung trích xuất từ tài liệu:
Lecture Java programming language: Conditional Control Structures - Ho Dac Hung Conditional Control Structures Ho Dac Hung1 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 java.util.Random class.8 Generating Random Number nextBoolean() nextDouble() nextFloat() nextInt() nextLong()9 Compound Boolean Expressions Conditions with complex criteria are formed using the && and || operators. How a compound boolean expression evaluates with && and || operators can be shown with truth tables.10 The Math Class Java includes the Math class in the java.lang package for performing math functions. abs pow sqrt floor ceil sin cos tan11 …
Nội dung trích xuất từ tài liệu:
Lecture Java programming language: Conditional Control Structures - Ho Dac Hung Conditional Control Structures Ho Dac Hung1 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 java.util.Random class.8 Generating Random Number nextBoolean() nextDouble() nextFloat() nextInt() nextLong()9 Compound Boolean Expressions Conditions with complex criteria are formed using the && and || operators. How a compound boolean expression evaluates with && and || operators can be shown with truth tables.10 The Math Class Java includes the Math class in the java.lang package for performing math functions. abs pow sqrt floor ceil sin cos tan11 …
Tìm kiếm theo từ khóa liên quan:
Java programming language Bài giảng ngôn ngữ lập trình Java he if-else statement The switch statement Generating random number The Math classGợi ý tài liệu liên quan:
-
Bài giảng Chương 1: Cơ bản về ngôn ngữ lập trình Java
19 trang 26 0 0 -
Bài giảng Ngôn ngữ lập trình Java: Chương 6.2 - TS. Phan Nguyên Hải
34 trang 25 0 0 -
Bài giảng Ngôn ngữ lập trình Java: Phần 2 - TS. Vũ Hữu Tiến
65 trang 24 0 0 -
Bài giảng Ngôn ngữ lập trình Java căn bản
115 trang 21 0 0 -
Bài giảng Công nghệ Java: Chương 0 - Trần Quang Diệu
6 trang 21 0 0 -
Lecture Introduction to Java programming - Chapter 15: Graphics
32 trang 21 0 0 -
Lecture Introduction to Java programming - Chapter 1: Introduction to computers, programs, and Java
63 trang 18 0 0 -
Bài giảng Ngôn ngữ lập trình Java: Chương 4 - TS. Phan Nguyên Hải
56 trang 18 0 0 -
Lecture Java programming language: Inheritance and Polymorphism - Ho Dac Hung
11 trang 17 0 0 -
Bài giảng Ngôn ngữ lập trình Java: Chương 5 - TS. Phan Nguyên Hải
33 trang 16 0 0