Презентация Programming logic and design seventh edition. Chapter 5. Looping онлайн
На нашем сайте вы можете скачать и просмотреть онлайн доклад-презентацию на тему Programming logic and design seventh edition. Chapter 5. Looping абсолютно бесплатно. Урок-презентация на эту тему содержит всего 38 слайдов. Все материалы созданы в программе PowerPoint и имеют формат ppt или же pptx. Материалы и темы для презентаций взяты из открытых источников и загружены их авторами, за качество и достоверность информации в них администрация сайта не отвечает, все права принадлежат их создателям. Если вы нашли то, что искали, отблагодарите авторов - поделитесь ссылкой в социальных сетях, а наш сайт добавьте в закладки.
Презентации » Устройства и комплектующие » Programming logic and design seventh edition. Chapter 5. Looping
Оцените!
Оцените презентацию от 1 до 5 баллов!
- Тип файла:ppt / pptx (powerpoint)
- Всего слайдов:38 слайдов
- Для класса:1,2,3,4,5,6,7,8,9,10,11
- Размер файла:957.06 kB
- Просмотров:69
- Скачиваний:0
- Автор:неизвестен
Слайды и текст к этой презентации:
№5 слайд
![Using a Loop Control Variable](/documents_6/89927a8ba35d7f6fdde232886e45dc4e/img4.jpg)
Содержание слайда: Using a Loop Control Variable
As long as a condition remains true, the statements in a while loop’s body execute
Control number of repetitions
Loop control variable initialized before entering loop
Loop control variable tested
Body of loop must alter value of loop control variable
Repetitions controlled by:
Counter
Sentinel value
№10 слайд
![Understanding the Loop in a](/documents_6/89927a8ba35d7f6fdde232886e45dc4e/img9.jpg)
Содержание слайда: Understanding the Loop in a Program’s Mainline Logic
Three steps should occur in every properly functioning loop
Provide a starting value for the variable that will control the loop
Test the loop control variable to determine whether the loop body executes
Alter the loop control variable
№15 слайд
![Avoiding Common Loop Mistakes](/documents_6/89927a8ba35d7f6fdde232886e45dc4e/img14.jpg)
Содержание слайда: Avoiding Common Loop Mistakes (continued)
Mistake: neglecting to alter the loop control variable
Remove get name instruction from outer loop
User never enters a name after the first one
Inner loop executes infinitely
Always incorrect to create a loop that cannot terminate
№17 слайд
![Avoiding Common Loop Mistakes](/documents_6/89927a8ba35d7f6fdde232886e45dc4e/img16.jpg)
Содержание слайда: Avoiding Common Loop Mistakes (continued)
Mistake: using the wrong comparison with the loop control variable
Programmers must use correct comparison
Seriousness depends on actions performed within a loop
Overcharge insurance customer by one month
Overbook a flight on airline application
Dispense extra medication to patients in pharmacy
№19 слайд
![Avoiding Common Loop Mistakes](/documents_6/89927a8ba35d7f6fdde232886e45dc4e/img18.jpg)
Содержание слайда: Avoiding Common Loop Mistakes (continued)
Mistake: including statements inside the loop that belong outside the loop
Example: discount every item by 30 percent
Inefficient because the same value is calculated 100 separate times for each price that is entered
Move outside the loop for efficiency
№24 слайд
![Using a for Loop continued](/documents_6/89927a8ba35d7f6fdde232886e45dc4e/img23.jpg)
Содержание слайда: Using a for Loop (continued)
while statement could be used in place of for statement
Step value: the amount by which a loop control variable changes
Can be positive or negative (incrementing or decrementing the loop control variable)
Default step value is 1
Programmer specifies a step value when each pass through the loop changes the loop control variable by a value other than 1
№27 слайд
![Common Loop Applications](/documents_6/89927a8ba35d7f6fdde232886e45dc4e/img26.jpg)
Содержание слайда: Common Loop Applications (continued)
Accumulators require three actions
Initialize the accumulator to 0
Accumulators are altered: once for every data set processed
At the end of processing, accumulators are output
Summary reports
Contain only totals with no detail data
Loops are processed but detail information is not printed
№30 слайд
![Using a loop to validate data](/documents_6/89927a8ba35d7f6fdde232886e45dc4e/img29.jpg)
Содержание слайда: Using a loop to validate data
Using a loop to validate data
Defensive programming: preparing for all possible errors before they occur
When prompting a user for data, no guarantee that data is valid
Validate data: make sure data falls in acceptable ranges (month values between 1 and 12)
GIGO: Garbage in, garbage out
Unvalidated input will result in erroneous output
№33 слайд
![Common Loop Applications](/documents_6/89927a8ba35d7f6fdde232886e45dc4e/img32.jpg)
Содержание слайда: Common Loop Applications (continued)
Limiting a reprompting loop
Reprompting can be frustrating to a user if it continues indefinitely
Maintain a count of the number of reprompts
Forcing a data item means:
Override incorrect data by setting the variable to a specific value
№34 слайд
![Common Loop Applications](/documents_6/89927a8ba35d7f6fdde232886e45dc4e/img33.jpg)
Содержание слайда: Common Loop Applications (continued)
Validating a data type
Validating data requires a variety of methods
isNumeric() or similar method
Provided with the language translator you use to write your programs
Black box
isChar() or isWhitespace()
Accept user data as strings
Use built-in methods to convert to correct data types
№37 слайд
![Summary Loops write one set](/documents_6/89927a8ba35d7f6fdde232886e45dc4e/img36.jpg)
Содержание слайда: Summary
Loops write one set of instructions that operate on multiple, separate sets of data
Three steps must occur in every loop
Initialize the loop control variable
Compare the variable to some value
Alter the variable that controls the loop
Nested loops: loops within loops
Nested loops maintain two individual loop control variables
Alter each at the appropriate time
№38 слайд
![Summary continued Common](/documents_6/89927a8ba35d7f6fdde232886e45dc4e/img37.jpg)
Содержание слайда: Summary (continued)
Common mistakes made by programmers
Neglecting to initialize the loop control variable
Neglecting to alter the loop control variable
Using the wrong comparison with the loop control variable
Including statements inside the loop that belong outside the loop
Most computer languages support a for statement
for loop used when the number of iterations is known
Loops are used to accumulate totals in business reports and to reprompt users for valid data
Скачать все slide презентации Programming logic and design seventh edition. Chapter 5. Looping одним архивом:
Похожие презентации
-
Programming Logic and Design Seventh Edition. Chapter 4. Making Decisions
-
Programming Logic and Design Seventh Edition. Chapter 1. An Overview of Computers and Programming
-
Programming Logic and Design Seventh Edition
-
Programming Logic and Design. Chapter 7. File Handling and Applications
-
Prolog. A general-purpose logic programming language associated with artificial intelligence and computational linguistics
-
Mathematical functions, characters, and strings. Introduction to Java Programming
-
Internet and Java Foundations, Programming and Practice
-
Operating systems and programming environments. МS DOS. Shell programs Norton Commander, Far Manager
-
Green technologies use in computer science and programming
-
Spring data. Familiar and consistent programming model for data access