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.

Slides:



Advertisements
Similar presentations
While loops.
Advertisements

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.
CHAPTER 5: LOOP STRUCTURES Introduction to Computer Science Using Ruby (c) 2012 Ophir Frieder et al.
Python Magic Select a Lesson: Why Learn to Code? Basic Python Syntax
Iteration (Looping Constructs in VB) Iteration: Groups of statements which are repeatedly executed until a certain test is satisfied Carrying out Iteration.
Do Loops A Do..Loop terminates based on a condition that is specified Execution of a Do..Loop continues while a condition is True or until a condition.
Chapter 61 Post Test Loop Do statement(s) Loop Until condition Loop is executed once and then the condition is tested. If it is False, the loop is run.
Handling Errors Introduction to Computing Science and Programming I.
Chapter 6 - VB.Net by Schneider1 Chapter 6 – Repetition 6.1 Do Loops 6.2 Processing Lists of Data with Do Loops Peek Method Counters and Accumulators Flags.
Do it now activity Correct the 8 syntax errors: Age = input(“How old are you?” If age = 10 Print(You are 10”) else: print(“You are not 10”)
CC0002NI – Computer Programming Computer Programming Er. Saroj Sharan Regmi Week 7.
Repetition Statements Repeating an Action A specified number of times While a Condition is True Until a Condition is True.
* What kind of loop would I use to complete the following: A. Output all of the prime numbers that are less than 100,000 B. Output the Fibonacci sequence.
1 Chapter 6 – Repetition 6.1 Do Loops 6.2 For...Next Loops 6.3 List Boxes and Loops.
Processing Lists of Data with Do Loops (Examples)
6.3 List Boxes and Loops Some Properties, Methods, and Events of List Boxes List Boxes Populated with Strings List Boxes Populated with Numbers Searching.
ENGR 112 Decision Structures.
CSD 340 (Blum)1 Ifs. CSD 340 (Blum)2 Page that asks user for background color and changes fore color from black if user selects black as background color.
Chapter 71 Repetition - Do Loops n A Loops, is used to repeat a sequence of statements a number of time n There are two loops commands in Visual Basic.
30/10/ Iteration Loops Do While (condition is true) … Loop.
Control Structures II Repetition (Loops). Why Is Repetition Needed? How can you solve the following problem: What is the sum of all the numbers from 1.
Chapter 16: Programming Structures Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 4 Looping.
Chapter 6 - VB.Net by Schneider1 Chapter 6 – Repetition 6.1 Do Loops 6.2 Processing Lists of Data with Do Loops Peek Method Counters and Accumulators Flags.
Simple Quiz Assessment David Yan Under the direction of Susan Rodger Duke University June 2015.
Chapter 16: Programming Structures Spreadsheet-Based Decision Support Systems Prof. Name Position (123) University Name.
Chapter 5: Control Structures: Iteration Visual Basic.NET Programming: From Problem Analysis to Program Design.
Conditional Loops CSIS 1595: Fundamentals of Programming and Problem Solving 1.
Chapter 6: Sections 6.2, 6.3 Roxana Gheorghiu Friday, April 1, 2011.
Looping Structures Do Loops, For Next Do...Loop While structures check the condition after executing the code and repeat a code block until the test.
Chapter 6 - VB 2005 by Schneider1 Chapter 6 – Repetition 6.1 Do Loops 6.2 Processing Lists of Data with Do Loops 6.3 For...Next Loops 6.4 A Case Study:
Agenda Perform Quiz #1 (20 minutes) Loops –Introduction / Purpose –while loops Structure / Examples involving a while loop –do/while loops Structure /
Basic Conditions. Challenge: ● Ask the user his/her name ● If it’s “Wally,” jeer him ● Pause video and try on your own.
Copyright © 2012 Pearson Education, Inc. Chapter 5: Loops.
Chapter 61 Example : For … To… Step For index = 0 To n Step s lstValues.Items.Add(index) Next Control variable Start value Stop value Amount to add to.
Controlling Program Flow with Looping Structures
Lecture 7: Menus and getting input. switch Multiple-selection Statement switch Useful when a variable or expression is tested for all the values it can.
UFCFY5-30-1Multimedia Studio Scripting for Interactive Media Further Structures for Branching and Looping.
Copyright 2006 Addison-Wesley Brief Version of Starting Out with C++ Chapter 5 Looping.
Escape sequence Certain characters, preceded by a backslash ( \ ), are known as escape sequences They are used to display certain characters, or as display.
While loops. Iteration We’ve seen many places where repetition is necessary in a problem. We’ve been using the for loop for that purpose For loops are.
5a – While Loops Lingma Acheson Department of Computer and Information Science, IUPUI CSCI N331 VB.NET Programming.
Dani Vainstein1 VBScript Session 5. Dani Vainstein2 What we learn last session? Branching Branching using If … Then … Else statement. Branching using.
Control Structures WHILE Statement Looping. S E Q C E N U E REPITITION …a step or sequence of steps that are repeated until some condition is satisfied.
COMPUTER PROGRAMMING I 5.05 Apply Looping Structures.
Chapter 6 Controlling Program Flow with Looping Structures.
Chapter 5 - VB 2008 by Schneider1 Chapter 5 – Repetition 5.1 Do Loops 5.2 Processing Lists of Data with Do Loops 5.3 For...Next Loops.
Chapter 6 - VB 2008 by Schneider1 Chapter 6 – Repetition 6.1 Do Loops 6.2 Processing Lists of Data with Do Loops 6.3 For...Next Loops 6.4 A Case Study:
1 Chapter 6 – Repetition 6.1 Do Loops 6.2 Processing Lists of Data with Do Loops 6.3 For...Next Loops 6.4 A Case Study: Analyze a Loan.
Loops causes program to execute the certain block of code repeatedly until some conditions are satisfied. Suppose you want to execute some code/s 10 times.
Follow up from lab See Magic8Ball.java Issues that you ran into.
Chapter 4 Repetition Statements (loops)
Introducing Do While & Do Until Loops & Repetition Statements
Chapter 6 – Repetition 6.1 Do Loops 6.2 For...Next Loops
Chapter 6 – Repetition 6.1 Do Loops 6.2 For...Next Loops
Visual Basic 6 Programming.
Chapter (3) - Looping Questions.
Introduction to TouchDevelop
Patterns to KNOW.
Module 4 Loops.
Chapter 8: More on the Repetition Structure
Chapter 6 - VB.Net by Schneider
JavaScript.
VB.Net Programming Console Application
Repetition Statements (Loops) - 2
Building Java Programs
True / False Variables.
Computer Science Club 1st November 2019.
Presentation transcript:

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.

Chapter 62 Lab sheet 6.5: Login Form

Chapter 63 Lab sheet 6.5 : Login Form - Code Dim username, password As String Dim LoginSuccess As Boolean = False Do Until LoginSuccess = True username = InputBox("Username Please") password = InputBox("Password Please") If username = "Peter" And password = "1234" Then LoginSuccess = True End If Loop MsgBox("Login success")

Chapter 64 More About Flags When flagVar is a variable of Boolean type, the statements If flagVar = True Then and If flagVar = False Then can be replaced by If flagVar Then and If Not flagVar Then

Chapter 65 Example: Login Form - Code Dim username, password As String Dim LoginSuccess As Boolean = False Do Until LoginSuccess = True username = InputBox("Username Please") password = InputBox("Password Please") If username = "Peter" And password = "1234" Then LoginSuccess = True End If Loop MsgBox("Login success")

Chapter 66 Flags continued The statements Do While flagVar = True and Do While flagVar = False can be replaced by Do While flagVar and Do While Not flagVar

Chapter 67 Yours Challenge ! Try to modify your program by limiting the number of try to 3. If a user enter incorrect username or password more than 3 times, system prompt an error message and does not allow user to try again. Hint: Use a counter variable to check the number of try and modify your Loop Condition.