TAILIEUCHUNG - Introduction to Programming Using Java Version 6.0 phần 2

Kể từ khi chúng tôi vẫn đang làm việc trên mức độ "lập trình nhỏ" trong chương này, chúng tôi đang quan tâm đến loại phức tạp có thể xảy ra trong một chương trình con duy nhất. Trên mức này, phức tạp được cung cấp bởi cấu trúc điều khiển. Hai loại cấu trúc điều khiển, các vòng lặp, | Chapter 3 Programming in the Small II Control The basic building blocks of programs variables expressions assignment statements and subroutine call statements were covered in the previous chapter. Starting with this chapter we look at how these building blocks can be put together to build complex programs with more interesting behavior. Since we are still working on the level of programming in the small in this chapter we are interested in the kind of complexity that can occur within a single subroutine. On this level complexity is provided by control structures. The two types of control structures loops and branches can be used to repeat a sequence of statements over and over or to choose among two or more possible courses of action. Java includes several control structures of each type and we will look at each of them in some detail. This chapter will also begin the study of program design. Given a problem how can you come up with a program to solve that problem We ll look at a partial answer to this question in Section . Blocks Loops and Branches The ABiLiTy of a computer to perform complex tasks is built on just a few ways of online combining simple commands into control structures. In Java there are just six such structures that are used to determine the normal flow of control in a program and in fact just three of them would be enough to write programs to perform any task. The six control structures are the block the while loop the loop the for loop the if statement and the switch statement. Each of these structures is considered to be a single statement but each is in fact a structured statement that can contain one or more other statements inside itself. Blocks The block is the simplest type of structured statement. Its purpose is simply to group a sequence of statements into a single statement. The format of a block is statements 63 CHAPTER 3. CONTROL 64 That is it consists of a sequence of statements enclosed between a pair of braces

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.