TAILIEUCHUNG - Lecter Java: Program design - Chapter 6: Iteration

In this chapter, we consider the while, for, and do-while looping constructs that control how many times a statement list is iterated (executed). Loops make programs much more powerful and capable of solving significant problems. Mastering the design and implementation of loops is an important part of a programmer's education. | Iteration Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Java looping Options while do-while for Allow programs to control how many times a statement list is executed Averaging Problem Extract a list of positive numbers from standard input and produce their average Numbers are one per line A negative number acts as a sentinel to indicate that there are no more numbers to process Observations Cannot supply sufficient code using just assignments and conditional constructs to solve the problem Don’t how big of a list to process Need ability to repeat code as needed Averaging Problem Extract a list of positive numbers from standard input and produce their average Numbers are one per line A negative number acts as a sentinel to indicate that there are no more numbers to process Algorithm Prepare for processing Get first input While there is an input to process do { Process current input Get the next input } Perform final processing Averaging .

TỪ KHÓA LIÊN QUAN
Đã 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.