Презентация Programming Logic and Design Seventh Edition. Chapter 4. Making Decisions онлайн
На нашем сайте вы можете скачать и просмотреть онлайн доклад-презентацию на тему Programming Logic and Design Seventh Edition. Chapter 4. Making Decisions абсолютно бесплатно. Урок-презентация на эту тему содержит всего 44 слайда. Все материалы созданы в программе PowerPoint и имеют формат ppt или же pptx. Материалы и темы для презентаций взяты из открытых источников и загружены их авторами, за качество и достоверность информации в них администрация сайта не отвечает, все права принадлежат их создателям. Если вы нашли то, что искали, отблагодарите авторов - поделитесь ссылкой в социальных сетях, а наш сайт добавьте в закладки.
Презентации » Устройства и комплектующие » Programming Logic and Design Seventh Edition. Chapter 4. Making Decisions
Оцените!
Оцените презентацию от 1 до 5 баллов!
- Тип файла:ppt / pptx (powerpoint)
- Всего слайдов:44 слайда
- Для класса:1,2,3,4,5,6,7,8,9,10,11
- Размер файла:1.01 MB
- Просмотров:76
- Скачиваний:0
- Автор:неизвестен
Слайды и текст к этой презентации:
№9 слайд
Содержание слайда: Using Relational
Comparison Operators
Relational comparison operators
Six types supported by all modern programming languages
Two values compared can be either variables or constants
Trivial expressions
Will always evaluate to the same result
Examples:
true for 20 = 20?
false for 30 = 40?
№11 слайд
Содержание слайда: Using Relational Comparison Operators (continued)
Any decision can be made with only three types of comparisons: =, >, and <
The >= and <= operators are not necessary but make code more readable
“Not equal” operator
Involves thinking in double negatives
Best to restrict usage to “if without an else”—that is, only take action when some comparison is false
№18 слайд
Содержание слайда: Nesting AND Decisions
for Efficiency
When nesting decisions
Either selection can come first
Performance time can be improved by asking questions in the proper order
In an AND decision, first ask the question that is less likely to be true
Eliminates as many instances of the second decision as possible
Speeds up processing time
№19 слайд
Содержание слайда: Using the AND Operator
Conditional AND operator
Ask two or more questions in a single comparison
Each Boolean expression must be true for entire expression to evaluate to true
Truth tables
Describe the truth of an entire expression based on the truth of its parts
Short-circuit evaluation
Expression evaluated only as far as necessary to determine truth
№24 слайд
Содержание слайда: Writing OR Decisions for Efficiency
May ask either question first
Both produce the same output but vary widely in number of questions asked
If first question is true, no need to ask second
In an OR decision, first ask the question that is more likely to be true
Eliminate as many extra decisions as possible
№25 слайд
Содержание слайда: Using the OR Operator
Conditional OR operator
Ask two or more questions in a single comparison
Only one Boolean expression in an OR selection must be true to produce a result of true
Question placed first will be asked first
Consider efficiency
Computer can ask only one question at a time
№28 слайд
Содержание слайда: Avoiding Common Errors
in an OR Selection
Second question must be a self-contained structure with one entry and exit point
Request for A and B in English logically means a request for A or B
Example
“Add $20 to the bill of anyone who makes more than 100 calls and to anyone who has used more than 500 minutes”
“Add $20 to the bill of anyone who has made more than 100 calls or has used more than 500 minutes”
№34 слайд
Содержание слайда: Making Selections within Ranges
Range check
Compare a variable to a series of values between limits
Use the lowest or highest value in each range
Adjust the question logic when using highest versus lowest values
Should end points of the range be included?
Yes: use >= or <=
No: use < or >
№37 слайд
Содержание слайда: Avoiding Common Errors When Using Range Checks
Avoid a dead or unreachable path
Don’t check for values that can never occur
Requires some prior knowledge of the data
Never ask a question if there is only one possible outcome
Avoid asking a question when the logic has already determined the outcome
№38 слайд
Содержание слайда: Understanding Precedence When Combining AND and OR Operators
Combine multiple AND and OR operators in an expression
When multiple conditions must all be true, use multiple ANDs
if score1 >= MIN_SCORE AND score2 >= MIN_SCORE AND score 3 >= MIN_SCORE then
classGrade = "Pass"
else
classGrade = "Fail"
endif
№40 слайд
Содержание слайда: Understanding Precedence When Combining AND and OR Operators (cont’d)
When AND and OR operators are combined in the same statement, AND operators are evaluated first
if age <= 12 OR age >= 65 AND rating = "G"
Use parentheses to correct logic and force evaluations to occur in the order desired
if (age <= 12 OR age >= 65) AND rating = "G"
№43 слайд
Содержание слайда: Summary
Decisions involve evaluating Boolean expressions
Use relational operators to compare values
An AND decision requires that both conditions be true to produce a true result
In an AND decision, first ask the question that is less likely to be true
An OR decision requires that either of the conditions be true to produce a true result
№44 слайд
Содержание слайда: Summary (continued)
In an OR decision, first ask the question that is more likely to be true
For a range check:
Make comparisons with the highest or lowest values in each range
Eliminate unnecessary or previously answered questions
The AND operator takes precedence over the OR operator
Скачать все slide презентации Programming Logic and Design Seventh Edition. Chapter 4. Making Decisions одним архивом:
-
Programming logic and design seventh edition. Chapter 5. Looping
-
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
-
System analysis and decision making Decision Trees
-
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