We will not cover the following sections in class: –7.2 –7.4 –7.8(we will discuss the design topics) You ARE responsible for knowing the topics covered.

Slides:



Advertisements
Similar presentations
Decision Structures - If / Else If / Else. Decisions Often we need to make decisions based on information that we receive. Often we need to make decisions.
Advertisements

Chapter 2 Flow of Control. Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 2-2 Learning Objectives Boolean Expressions Building, Evaluating.
Chapter 13 Control Structures. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display Control Structures Conditional.
XSL November 4, Unit 6. Default sorting is based on text However, we can also sort on numbers, more successfully than last class We use the data-type.
1 Chapter Five Selection and Repetition. 2 Objectives How to make decisions using the if statement How to make decisions using the if-else statement How.
Pascal Programming Today Chapter 4 1 »Conditional statements allow the execution of one of a number of possible operations. »Conditional statements include:
James Tam Making Decisions In Pascal In this section of notes you will learn how to have your Pascal programs choose between alternative courses of action.
James Tam Making Decisions In Pascal In this section of notes you will learn how to have your Pascal programs choose between alternative courses of action.
July 13 th.  If/ Else if / Else  Variable Scope  Nested if/else's  Switch statements  Conditional Operator.
Decisions (Conditional Programming) Chapter 5 (Sec. 5.1 & 5.2)
Basic Elements of Programming A VB program is built from statements, statements from expressions, expressions from operators and operands, and operands.
2-1 Making Decisions Sample assignment statements PayAmount = Hours * Rate PayAmount = 40*Rate + (Hours – 40)*Rate*1.5.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 4: Control Structures I (Selection)
true (any other value but zero) false (zero) expression Statement 2
James Tam Making Decisions In Pascal In this section of notes you will learn how to have your Pascal programs choose between alternative courses of action.
James Tam Making Decisions In Pascal In this section of notes you will learn how to have your Pascal programs choose between alternative courses of action.
Visual C++ Programming: Concepts and Projects
James Tam Making Decisions In Pascal In this section of notes you will learn how to have your Pascal programs choose between alternative courses of action.
Quiz 1 Exam 1 Next Week. Nested if Statements if (myGrade >= 80) if (myGrade >= 90) cout
Slides prepared by Rose Williams, Binghamton University Chapter 3 Flow of Control if-else and switch statements.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 4 Decision Structures and Boolean Logic.
True or False: Boolean Expression Boolean expression are expressions which evaluate to "true" or "false“ Primary operators to combine expressions: && (and),
Decision Structures and Boolean Logic
Using the selection structure (Unit 7) Visual Basic for Applications.
Programming Fundamentals. Today’s lecture Decisions If else …… Switch Conditional Operators Logical Operators.
Control Structures – Selection Chapter 4 2 Chapter Topics  Control Structures  Relational Operators  Logical (Boolean) Operators  Logical Expressions.
Chapter 4: Making Decisions. Understanding Logic-Planning Tools and Decision Making Pseudocode – A tool that helps programmers plan a program’s logic.
Selection (if-then-else) Programming Has 3 Types of Control: Sequential (normal): Control of Execution Proceeds One after the Other Selection (if-then-else):
1 Conditions Logical Expressions Selection Control Structures Chapter 5.
Selection Structure If... Then.. Else Case. Selection Structure Use to make a decision or comparison and then, based on the result of that decision or.
1. We’ve learned that our programs are read by the compiler in order, from top to bottom, just as they are written The order of statement execution is.
Making Decisions Chapter 5.  Thus far we have created classes and performed basic mathematical operations  Consider our ComputeArea.java program to.
CHAPTER 4: Selection Control Structure. Objectives  Use the relational comparison operators  Learn about AND logic  Learn about OR logic  Make selections.
Chapter 5 Logic; Got Any?. Flow of Control The order in which the computer executes statements in a program Control Structure A statement used to alter.
If…else statements. Boolean Expressions Boolean expression - An expression whose value is either true or false true = 1 false = 0 Datatype: boolean.
Decision making statements. Decision making statements are used to skip or to execute a group of statements based on the result of some condition. The.
1 09/15/04CS150 Introduction to Computer Science 1 Life is Full of Alternatives Part 2.
Copyright 2003 Scott/Jones Publishing Making Decisions.
 Control Flow statements ◦ Selection statements ◦ Iteration statements ◦ Jump statements.
An Object-Oriented Approach to Programming Logic and Design Chapter 5 Making Decisions.
Midterm Exam Topics (Prof. Chang's section) CMSC 201.
Decision Statements, Short- Circuit Evaluation, Errors.
Midterm1 answers: Page 1 1 a6 b6 c0 2 ***. Midterm1 answers: Page 2 A)a. 53b. 44c. 13d. 75e. 77 B)a. 53b. 17c. 33 / 44d. 13e. 75 C)a. ‘5’b. ‘3’c. ‘ ‘d.
STRUCTURED PROGRAMMING Selection Statements. Content 2  Control structures  Types of selection statements  if single-selection statement  if..else.
Pascal Programming George Boole, a 19 th Century mathematician, is created with true, false logic. A Boolean expression in Pascal will be true or false.
Chapter 5 – Decision Making. Structured Programming Sequence Selection Repetition yesno yes no.
Copyright 2004 Scott/Jones Publishing Alternate Version of STARTING OUT WITH C++ 4 th Edition Chapter 4 Making Decisions.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 2: Control Structures (Selection & Repetition)
Selection (if-then-else) Programming Has 3 Types of Control: Sequential (normal): Control of Execution Proceeds One after the Other Selection (if-then-else):
Chapter 3 Selection Statements
Sequence, Selection, Iteration The IF Statement
Control Structures Combine individual statements into a single logical unit with one entry point and one exit point. Used to regulate the flow of execution.
Operator Precedence Operators Precedence Parentheses () unary
Topics The if Statement The if-else Statement Comparing Strings
JavaScript: Control Statements I
Control Structures – Selection
Topics The if Statement The if-else Statement Comparing Strings
Boolean Expressions and If statements
2-1 Making Decisions Sample assignment statements
The C++ IF Statement Part 2 Copyright © Curt Hill
Control Structures: Selection Statement
The System.exit() Method
Lecture Notes – Week 2 Lecture-2
Chapter 5: Selection Statement
Understanding Conditions
Chapter 4: Boolean Expressions, Making Decisions, and Disk Input and Output Prof. Salim Arfaoui.
Control Structures: Selection Statement
The Selection Structure
Chapter 3: Selection Structures: Making Decisions
Chapter 2 Sets Active Learning Lecture Slides
Presentation transcript:

We will not cover the following sections in class: –7.2 –7.4 –7.8(we will discuss the design topics) You ARE responsible for knowing the topics covered in these sections. The topics are covered in the other sections of the chapter. However, these sections contain very good examples and you should study them.

Boolean Operators:AND If (BoolEx1) AND (BoolEx2) THEN writeln(‘Both expressions are true’); When using the AND Operator, both expressions must be TRUE for the compound expression to be true.

Boolean Operators:OR If (BoolEx1) OR (BoolEx2) THEN writeln(‘At least one expression is true’); When using the OR Operator, at least one expression must be TRUE for the compound expression to be true.

Boolean Operators: NOT If NOT (BoolEx) THEN writeln(‘BoolEx is FALSE’); The NOT Operator simply reverses the boolean value of the boolean expression that appears immediately to its right. NOT (a <= 2) OR (b = 2) will evaluate to TRUE if a is greater than 2 and / or b =2.

Pascal Sets In Pascal you can define sets by placing a group of ‘elements’ of any single ordinal type between brackets. –[‘A’, ‘E’, ‘I’, ‘O’, ‘U’] –[1..9]{all values between 1 and 9}

Pascal Sets: The IN operator The boolean operator IN is used to test whether an item is an element of a set. FOR Letter := ‘A’ TO ‘Z’ DO IF Letter IN [‘A’, ‘E’, ‘I’, ‘O’, ‘U’] THEN write(letter);

Precedence Priority Operator(s) 1stNOT 2ndAND, *, /, DIV, MOD 3rdOR, +, - 4th=, <>, >, =, <=, IN

Section 7.7 Skip for now we may revisit include files

Sections 7.8 Per first slide, we will discuss the design issues in another class. You should read and “grok” this section’s example

Nested IF Statements When you nest IF statements, an else will match to the closest ‘non-matched’ IF. IF Age >= 21 THEN IF Age <= 35 THEN writeln(‘come in’) ELSE writeln(‘Do you know this is a college bar’); The ELSE will match with IF AGE <= 35

Multiple Alternative IF-THEN-ELSE The multiple IF-THEN-ELSE is a multiway switch that allows you to choose only one of many options. IF A < 10 THEN … ELSE IF A < 15 THEN … ELSE...

Homework #6 Due next Thursday, November 11 On Marateck’s website homework #5 The assignment is like a “version 2.0” of the one due today.