True / False Variables.

Slides:



Advertisements
Similar presentations
Chapter 4 - Control Statements
Advertisements

CS107 Introduction to Computer Science Lecture 3, 4 An Introduction to Algorithms: Loops.
While Loops. Challenge: ● Ask the user a simple math questions ● Continue asking the question until the user gets it right.
CS0004: Introduction to Programming Repetition – Do Loops.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Chapter 61 Flags A flag is a variable that keeps track of whether a certain situation has occurred. The data type most suited to flags is Boolean.
© 1999, by Que Education and Training, Chapter 7, pages of Introduction to Computer Programming with Visual Basic 6: A Problem-Solving Approach.
Loops Doing the same thing over and over and over and over and over and over…
Branching and Looping Examples, cont’d. Remember the generic triple jump world…
Repetition Statements Repeating an Action A specified number of times While a Condition is True Until a Condition is True.
Chapter 61 More about Loop Do ….. Loop Write Down “Do” and “Loop”
08/10/ Iteration Loops For … To … Next. 208/10/2015 Learning Objectives Define a program loop. State when a loop will end. State when the For.
While Loops Indefinite Iteration. Last lesson we looked at definite loops using the ‘For’ statement. The while loop keeps going while some condition is.
Programming Fundamentals. Today’s lecture Decisions If else …… Switch Conditional Operators Logical Operators.
For Loops 1 Loops/Iteration Used to repeat an action Must have a STOP condition Three flavors - for, while, do/while Which loop to use? task with a specific.
Logic Structure - focus on looping Please use speaker notes for additional information!
Mastery Objective: Students will understand how to use while loops in computer programming.
Implementation of the Hangman Game in C++
A Simple Quiz: Ask User Functions. By Lana Dyck under the direction of Professor Susan Rodger Duke University June 2009, added Part 2 July 2011.
Lecture 4 Looping. Building on the foundation Now that we know a little about  cout  cin  math operators  boolean operators  making decisions using.
GAME102 - INTRO WHILE LOOPS G. MacKay. Fundamental Control Structures  STRAIGHT LINE  CONDITIONAL  LOOPS.
 There are times when you will want blocks to repeat. Instead of duplicating blocks and ending up with a long script that might be confusing, there.
ITEC 109 Lecture 11 While loops. while loops Review Choices –1 st –2 nd to ?th –Last What happens if you only use ifs? Can you have just an else by itself?
Review while loops Control variables Example Infinite loop
Copyright © 2012 Pearson Education, Inc. Chapter 5: Loops.
Radio Buttons. Input/Form/Radio Group Use the dialog to enter label and values for the radio buttons.
GCSE Computing#BristolMet Session Objectives #23 MUST understand what is meant by the programming term iteration SHOULD describe methods of looping used.
FOR LOOPS "LOOP FOR A SET NUMBER OF TIMES.". FOR ( START_VALUE; END_VALUE; INCREMENT_NUMBER ) { //YOUR_CODE_HERE } So after the word "for" (in lowercase)
Microsoft® Small Basic Conditions and Loops Estimated time to complete this lesson: 2 hours.
TOPIC 8 MORE ON WHILE LOOPS 1 Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson,
Solving Problems with Repetition Version 1.0. Objectives At the end of this topic, students should be able to: Correctly use a while statement in a C#
Adapted by Mrs. Garay. Warm Up Solve. 1. 2x + 9x – 3x + 8 = – 4 = 6x + 22 – 4x 3. + = 5 4. – = 3 x = 1 x = –13 x = x x9x 16 2x2x 4.
Sensor Information: while loops and Boolean Logic.
Zhen Jiang Dept. of Computer Science West Chester University West Chester, PA CSC530 Data Structures - LOOP 7/9/20161.
Standard and Expanded Form
Tutorial 10 – Class Average Application Introducing the Do…Loop While and Do…Loop Until Repetition Statements Outline Test-Driving the Class Average.
Java for Beginners.
Chapter 5: Loops and Files.
Using the Stopwatch object
Programming Fundamentals
Iterations Programming Condition Controlled Loops (WHILE Loop)
Using the Priming Read Priming read (or priming input):
And the text with form..
While loops The while loop executes the statement over and over as long as the boolean expression is true. The expression is evaluated first, so the statement.
Iteration with While You can say that again.
Computers & Programming Languages
More Loops.
Welcome back to Software Development!
Scratch: selection / branching/ if / If…else / compound conditionals / error trapping by Mr. Clausen.
Welcome back to Software Development!
Welcome back to Software Development!
Patterns to KNOW.
IPC144 Introduction to Programming Using C Week 3 – Lesson 2
Logical Operations In Matlab.
Three Special Structures – Case, Do While, and Do Until
Solving One and Two Step Equations
SECTION 2-4 : SOLVING EQUATIONS WITH THE VARIABLE ON BOTH SIDES
Variables & getting info from the user
CSCI N207 Data Analysis Using Spreadsheet
Clear and Unclear Windows
Repetition Statements (Loops) - 2
Topics discussed in this section:
Variables and Equations
Learning Intention I will learn about the standard algorithm for input validation.
Tic-Tac-Toe Game Engine
Basic program gives only one quess and then the program ends.
Starter Look at the hand-out.
Iteration – While Loops
Presentation transcript:

True / False Variables

True / False Variables: Bool Variables bool keepLooping; type name

True / False Variables: Bool Variables bool keepLooping; keepLooping = true; while ( keepLooping == true ) { … }

True / False Variables: Bool Variables bool keepLooping; keepLooping = true; while ( keepLooping ) { … }

True / False Variables: Bool Variables bool haveValidInput; haveValidInput = false; while (haveValidInput == false) { … }

True / False Variables: Bool Variables bool haveValidInput; haveValidInput = false; while ( !haveValidInput ) { … }

True / False Variables: Bool Variables bool haveValidInput; haveValidInput = false; while ( !haveValidInput ) { … }

True / False Variables: Bool Variables bool haveValidInput; haveValidInput = false; while ( !haveValidInput ) { … }

Logical Operators: And / Or

Logical Operators: And / Or

Logical Operators: And / Or

Logical Operators: And / Or Example: if ( temp > 32 && temp < 50 ) isChilly = true; if ( temp < 32 || temp > 90 ) yuckyWeather = true;

Your task… New project named bool Write a program that : Asks the user a yes/no question Loops until the user has entered a valid answer Which logical operator do you need to use in the loop condition check? Is this an “and” or an “or” question?

Your task continued… Add to your bool project… Asks the user the yes/no question again Loop until the user has entered a valid answer This time, use a single bool variable as the loop control variable

Clear and Unclear Windows