Lecture An introduction to computer science using java (2nd Edition): Chapter 4 - S.N. Kamin, D. Mickunas, E. Reingold

29 51 0
Lecture An introduction to computer science using java (2nd Edition): Chapter 4 - S.N. Kamin, D. Mickunas, E. Reingold

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Chapter 4 - Decision making. In this chapter we will: discuss the use of decision making in computer programming, describe the use of the Java if and switch statements, describe the use of Boolean expressions in Java if statements, discuss the use of integer selector variables in Java switch statements.

Chapter Decision Making Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N Kamin, D Mickunas, E Reingold     Chapter Preview In this chapter we will: • discuss the use of decision making in computer programming • describe the use of the Java if and switch statements • describe the use of Boolean expressions in Java if statements • discuss the use of integer selector variables in Java switch statements     if Statement • Ensures that a statement is executed only when a condition is true • Conditions typically involve comparison of variables or quantities for equality or inequality • Example: if (age >= 18) out.println(“You are eligible to vote.”);         Relational Operators < < less than > > greater than = greater than or equal to = == equal to != not equal to     if Statement with Optional else • An if statement may have an optional else clause that will only be executed when the condition is false • Example: if (wages > greater than

Ngày đăng: 11/01/2020, 20:31

Mục lục

  • if Statement with Optional else

  • Boolean Operator Truth Table

  • Java String Class Comparison Methods

  • Why is break used in switch statements?

  • Symbolic Constants in switch Statements

  • Multiple case Labels in switch Statements

  • Comparing switch and if statements

  • Building Classes with Multiple Methods

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan