Tutorial 10 – Class Average Application Introducing the Do…Loop While and Do…Loop Until Repetition Statements Outline 10.1 Test-Driving the Class Average.

Slides:



Advertisements
Similar presentations
Lists, Loops, Validation, and More
Advertisements

© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 12 – Security Panel Application Introducing.
Chapter 6: The Repetition Structure
Microsoft Visual Basic: Reloaded Chapter Seven More on the Repetition Structure.
Microsoft Visual Basic: Reloaded Chapter Six Repeating Program Instructions.
Iteration (Looping Constructs in VB) Iteration: Groups of statements which are repeatedly executed until a certain test is satisfied Carrying out Iteration.
1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures 4.5 if Single-Selection Statement 4.6 if else Selection Statement 4.7 while.
5.05 Apply Looping Structures
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 6 – Car Payment Calculator Application: Introducing.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 9 Car Payment Calculator Application Introducing the Do While...Loop and Do Until...Loop.
Visual Basic Fundamental Concepts. Integrated Development Enviroment Generates startup form for new project on which to place controls. Features toolbox.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 8 - JavaScript: Control Structures I Outline 8.1 Introduction 8.2 Algorithms 8.3 Pseudocode 8.4.
Repetition Statements Repeating an Action A specified number of times While a Condition is True Until a Condition is True.
110-K1 Iterations (1) Up to now, need to call the procedure again (e.g. click again on a command button) To repeat a piece of code: Can also use loops:
Microsoft Visual Basic 2010: Reloaded Fourth Edition Chapter Six Repeating Program Instructions.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Interest Calculator Application Introducing the For...Next Repetition Statements.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Shipping Hub Application Introducing Generic Collections, LINQ, For Each...Next.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 8 - Interest Calculator Application: Introducing.
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.
Chapter 12: How Long Can This Go On?
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 7.1 Test-Driving the Wage Calculator Application.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 6 – Car Payment Calculator Application: Introducing.
1 Week 6 The Repetition Structure. 2 The Repetition Structure (Looping) Lesson A Objectives After completing this lesson, you will be able to:  Code.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 17 – Flag Quiz Application Introducing One-Dimensional.
ISAT 252 Visual Basic Repetition. Assignment Should have read Chapter 5 ( ) on loops Do tutorial 5-4.
Chapter 6: The Repetition Structure
Tutorial 6 The Repetition Structure
COMPUTER PROGRAMMING I 5.05 Apply Looping Structures.
Visual Basic Programming
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Class Average Application Introducing the Do...Loop While and Do...Loop Until.
1 JavaScript: Control Structures. 2 Control Structures Flowcharting JavaScript’s sequence structure.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 7 – Class Average Application: Introducing.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 20.1 Test-Driving the Shipping Hub Application.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.1.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 18 – Student Grades Application Introducing.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.1.
For…Next Loops, Checked List Boxes, and Combo Boxes Chapter 5.
MIS 3200 – Unit 5.1 Iteration (looping) – while loops – for loops Working with List Items.
31/01/ Selection If selection construct.
Tutorial 6: The Repetition Structure1 Tutorial 6 The Repetition Structure.
Controlling Program Flow with Looping Structures
Design the form above that calculates GPAs. It has a ComboBox of grades, a NumericUpDown control for credits, a button to add grades and credits to two.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Student Grades Application Introducing Two-Dimensional Arrays and RadioButton.
Input Boxes, List Boxes, and Loops Chapter 5. 2 Input Boxes Method for getting user’s attention to obtain input. InputBox() for obtaining input MessageBox()
Fourth Quarter.  Involves loops or cycles ◦ Loops: means that a process may be repeated as long as certain condition remains true or remains false. ◦
Loop Blocks Chapter 6 Part A. Program Blocks 1.Actions- commands, messages, methods 2.Branches- decisions to be made 3.Loops- actions to be repeated.
 2003 Prentice Hall, Inc. All rights reserved. 1 Outline 11.1 Test-Driving the Interest Calculator Application 11.2 Essentials of Counter-Controlled Repetition.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
JavaScript: Control Structures I Outline 1 Introduction 2 Algorithms 3 Pseudocode 4 Control Structures 5 if Selection Structure 6 if/else Selection Structure.
Visual Basic Fundamental Concepts
while Repetition Structure
Visual Basic 6 (VB6) Data Types, And Operators
Tutorial 9 - Car Payment Calculator Application Introducing the while Repetition Statement Outline 9.1 Test-Driving the Car Payment Calculator Application.
3rd prep. – 2nd Term MOE Book Questions.
Introducing Do While & Do Until Loops & Repetition Statements
Chapter 6 – Repetition 6.1 Do Loops 6.2 For...Next Loops
Chapter 4 LOOPS © Bobby Hoggard, Department of Computer Science, East Carolina University / These slides may not be used or duplicated without permission.
Visual Basic..
Tutorial 12 – Security Panel Application Introducing the Select Case Multiple-Selection Statement Outline Test-Driving the Security Panel Application.
Tutorial 19 - Microwave Oven Application Building Your Own Classes and Objects Outline Test-Driving the Microwave Oven Application Designing.
حلقات التكرار.
More Loops.
1) C program development 2) Selection structure
Chapter (3) - Looping Questions.
CIS 16 Application Development Programming with Visual Basic
Introduction to Problem Solving and Control Statements
Write a program that places the names of five different states in labels, and allows the user to enter guesses of the corresponding state capitals in textboxes.
MIS 3200 – Unit 5.1 Iteration (looping) Working with List Items
Presentation transcript:

Tutorial 10 – Class Average Application Introducing the Do…Loop While and Do…Loop Until Repetition Statements Outline 10.1 Test-Driving the Class Average Application 10.2 Do…Loop While Repetition Statement 10.3 Do…Loop Until Repetition Statement 10.4 Creating the Class Average Application 10.5 Wrap-Up

In this tutorial, you will learn to: Objectives In this tutorial, you will learn to: Use the Do…Loop While statement. Use the Do…Loop Until statement. Understand counter-controlled repetition. Transfer the focus to a control. Enable and disable Buttons.

10.1 Test-Driving the Class Average Application

10.1 Test-Driving the Class Average Application Figure 10.1 Class Average application’s Form in run mode. Output Label The Class Average application Output Label displays quiz average to user

10.1 Test-Driving the Class Average Application Figure 10.2 Entering grades in the Class Average application. Entering quiz grades Enter a grade into the Enter grade: TextBox Click Add Grade Button Grade added to ListBox Focus given to TextBox

10.1 Test-Driving the Class Average Application Figure 10.3  Class Average application after 10 grades have been input. Disabled Add Grade Button Ten quiz grades entered Entering ten grades Add Grade Button disabled Click Average Button to calculate average quiz grade

10.1 Test-Driving the Class Average Application Figure 10.4 Displaying the class average. Label displaying average Click to calculate class average Calculating the average Click the Average Button Average displayed in output Label Add Grade Button enabled

10.1 Test-Driving the Class Average Application Figure 10.5 Entering a new set of grades. Entering another set of grades Old quiz grades removed from ListBox New grade added to ListBox

10.2 Do…Loop While Repetition Statement Do…Loop While example: Dim intCouner As Integer = 1 Do 1stDisplay.Items.Add(intCounter) intCounter += 1 Loop While intCounter <= 3 Set counter to 1 Excecute body of Do…Loop While statement while the counter is less than or equal to 3

10.2 Do…Loop While Repetition Statement Figure 10.6 Do…Loop While repetition statement UML activity diagram. Corresponding VB .NET Statements: lstDisplay.Items.Add(intCounter) action state intCounter += 1 [intCounter <= 3] decision loop- [intCounter > 3] continuation condition Do…Loop While repetition statement Body of the loop executes first Loop-continuation condition checked If False, loop exits If True, loop executes again

10.3 Do…Loop Until Repetition Statement Do…Loop Until example: Dim intCouner As Integer = 1 Do 1stDisplay.Items.Add(intCounter) intCounter += 1 Loop Until intCounter > 3 Set counter to 1 Execute body of Do…Loop Until statement until the counter is greater than to 3

10.3 Do…Loop Until Repetition Statement Figure 10.7 Do…Loop Until repetition statement UML activity diagram. Corresponding VB .NET Statements: lstDisplay.Items.Add(intCounter) action state intCounter += 1 [intCounter <= 3] Decision [intCounter > 3] Do…Loop Until repetition statement Body of the loop executes Loop-continuation condition checked If False, loop executes again If True, loop exits

10.4 Creating the Class Average Application

10.4 Creating the Class Average Application

10.4 Creating the Class Average Application Figure 10.9 Class Average application’s Form in design view. Template application Contains: ListBox Buttons Output Label

10.4 Creating the Class Average Application Figure 10.10 Clearing the ListBox and output Label after a calculation. Clearing the grade list and class average Clearing ListBox and output Label If output Label contains text Clear output Label of previous result Clear ListBox of previous quiz grades

10.4 Creating the Class Average Application Figure 10.11 Adding the grade input to the ListBox and clearing the Enter grade: TextBox. Adding a numeric grade to the ListBox and clearing the user input from the TextBox Displaying grades Add grade to ListBox Clear TextBox txtInput

10.4 Creating the Class Average Application Figure 10.12 Transferring the focus to the TextBox control. Transferring the focus of the application to the TextBox Transferring focus to a control Makes application easier to use Use method Focus of that control

10.4 Creating the Class Average Application Accepting ten grades Use method lstGrades.Items.Count to determine if ten grades entered If ten grades entered: Disable Add Grade Button Give focus to Average Button

10.4 Creating the Class Average Application Figure 10.13 Application accepts only 10 grades. Disabling the Add grade Button and transferring the focus to the Average Button

10.4 Creating the Class Average Application Initializing event handler variables intTotal stores sum of all quiz grades intGradeCounter stores number of grades entered intGrade stores current grade entered dblAverage stores average of quiz grades

10.4 Creating the Class Average Application Figure 10.14 Initialization phase of class-average calculation. Initializing variables

10.4 Creating the Class Average Application Figure 10.15 Do…Loop Until summing grades. Using the Do…Loop Until repetition statement to sum grades in the ListBox.

10.4 Creating the Class Average Application Adding quiz grades Use a Do…Loop Until statement to retrieve ten grades Use lstGrades.Items.Item() to retrieve grade from ListBox Add grade to intTotal Increment counter

10.4 Creating the Class Average Application Displaying average Calculate average of ten quiz grades Format and display average Enable Add Grade Button Transfer the focus to txtInput TextBox

10.4 Creating the Class Average Application Figure 10.16 Displaying the result of the average calculation. Calculating the class average, enabling the Add Grade Button, and transferring the focus to the Enter Grade: TextBox.

ClassAverage.vb (1 of 3) Disabling the Add Grade Button and transferring the focus to the Average Button

ClassAverage.vb (2 of 3) Using a Do…Loop Until statement to calculate the class average

Enabling the Add Grade Button and transferring the focus to the Enter grade: TextBox ClassAverage.vb (3 of 3)