Đang chuẩn bị liên kết để tải về tài liệu:
Lecture An introduction to computer science using java (2nd Edition): Chapter 6 - S.N. Kamin, D. Mickunas, E. Reingold

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

Chapter 6 - Iteration. In this chapter we will: discuss the use of repetition (iteration) in programming algorithms; describe the Java while, for, and do-while statements; demonstrate the use of loop invariants to verify the correctness of loops; show the use of loops in data entry and computer animation. | Chapter 6 Iteration 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 repetition (iteration) in programming algorithms describe the Java while, for, and do-while statements demonstrate the use of loop invariants to verify the correctness of loops show the use of loops in data entry and computer animation while Loop Repeated executes body of the loop which can be a single or compound statement A while loop will execute as long as its condition is true An infinite loop will occur if the condition never becomes false Example: count = 1; while (count <= 10) count = count + 1; while Loop From Temperature Conversion Program OutputBox out = new OutputBox( ); out.println(“\tDEGREES C\tDEGREES F”); // initialize the loop variable cent = LOW_TEMP; // test the loop variable while (cent <= HIGH_TEMP) { // convert C to F fahr = (9.0 / 5.0) * cent + 32.0; out.println(“\t” + cent “\t\t” fahr); // increment loop variable cent = cent + 1.0; } for Statement Used to implement pre-test loops that are controlled by incrementing a variable each time the loop is executed Loop variable computations for initialization, testing, and incrementing appear in a single statement Example: for(count=1; count <= 10; count = count + 1); Comparing for and while Done using for for ( statement1; condition; statement2 ) statement 3; Equivalent while loop statement1; while (condition) { statement3; statement2; } Temperature Conversion Program Loop Implemented Using for OutputBox out = new OutputBox( ); out.println(“\tDEGREES C\tDEGREES F”); for (cent = LOW_TEMP; cent <= HIGH_TEMP; cent = cent + 1.0;) { // convert C to F fahr = (9.0 / 5.0) * cent + 32.0; out.println(“\t” + cent “\t\t” fahr); } do-while Statement Used to implement post-test loops that always execute the loop body at least one time A do-while loop will continue execute as long as its condition is true An | Chapter 6 Iteration 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 repetition (iteration) in programming algorithms describe the Java while, for, and do-while statements demonstrate the use of loop invariants to verify the correctness of loops show the use of loops in data entry and computer animation while Loop Repeated executes body of the loop which can be a single or compound statement A while loop will execute as long as its condition is true An infinite loop will occur if the condition never becomes false Example: count = 1; while (count <= 10) count = count + 1; while Loop From Temperature Conversion Program OutputBox out = new OutputBox( ); out.println(“\tDEGREES C\tDEGREES F”); // initialize the loop variable cent = LOW_TEMP; // test the loop variable while (cent <= HIGH_TEMP) { // convert C to F fahr = (9.0 / 5.0) * cent + 32.0; .

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.