1. Trang chủ
  2. » Công Nghệ Thông Tin

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

29 51 0

Đ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

Thông tin cơ bản

Định dạng
Số trang 29
Dung lượng 504,21 KB

Nội dung

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