Program variables Counters Accumulators Major and minor totals Control Click icon to hear comments (the download may take a minute )

Slides:



Advertisements
Similar presentations
Programming with Microsoft Visual Basic 2008 Fourth Edition
Advertisements

Programming with Microsoft Visual Basic th Edition
Chapter 04 (Part III) Control Statements: Part I.
The art of drawing a road map
Programming Logic and Design, Third Edition Comprehensive
Programing Concept Ken Youssefi/Ping HsuIntroduction to Engineering – E10 1 ENGR 10 Introduction to Engineering (Part A)
Chapter 5: Control Structures II (Repetition)
Chapter 5: Control Structures II (Repetition)
Control Structures: Part 2. Introduction Essentials of Counter-Controlled Repetition For / Next Repetition Structure Examples Using the For / Next Structure.
Loops Repeat after me …. Loops A loop is a control structure in which a statement or set of statements execute repeatedly How many times the statements.
Repeating Program Instructions Chapter Microsoft Visual Basic.NET: Reloaded 1.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 7 – Class Average Application: Introducing.
Computer Science A 14: 3/4. Computing with numbers - Precision - Representation - Computing with numbers - Example.
Grade 9 Integer Review Review Day 1.
Chapter 5: Control Structures II (Repetition)
C++ Programming: Program Design Including Data Structures, Fourth Edition Chapter 5: Control Structures II (Repetition)
10- 1 Chapter 10. To familiarize you with  Main types of computer-generated reports  Techniques used for efficient printing of group reports and control.
Chapter 5: Control Structures II (Repetition)
CHAPTER 5: CONTROL STRUCTURES II INSTRUCTOR: MOHAMMAD MOJADDAM.
EGR 2261 Unit 5 Control Structures II: Repetition  Read Malik, Chapter 5.  Homework #5 and Lab #5 due next week.  Quiz next week.
CIS 115 Lecture 8. There are 3 control structures common to most computer languages that determine the flow, or path of execution, of the code:  Sequential.
Lecture 4 C Program Control Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
Programming Logic and Design Fifth Edition, Comprehensive
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 5 Arrays.
6 Chapter 61 Looping Programming Logic and Design, Second Edition, Comprehensive 6.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 6 Looping.
 Wednesday, 9/18/02, Slide #1 CS106 Introduction to CS1 Wednesday, 9/18/02  QUESTIONS?? HW #1 due today at 5!!  Today: Loops, and two new data types.
C++ Programming: From Problem Analysis to Program Design, Second Edition Chapter 5: Control Structures II (Repetition)
Chapter 5 Control Structure (Repetition). Objectives In this chapter, you will: Learn about repetition (looping) control structures Explore how to construct.
Chapter 5: Control Structures II (Repetition). Objectives In this chapter, you will: – Learn about repetition (looping) control structures – Learn how.
Control Structures II (Repetition). Objectives In this chapter you will: Learn about repetition (looping) control structures Explore how to construct.
An Introduction to Programming with C++ Sixth Edition Chapter 7 The Repetition Structure.
PROBLEM SOLVING WITH LOOPS Chapter 7. Concept of Repetition Structure Logic It is a computer task, that is used for Repeating a series of instructions.
CS101 Computer Programming I Chapter 4 Extra Examples.
Pointers: Basics. 2 What is a pointer? First of all, it is a variable, just like other variables you studied  So it has type, storage etc. Difference:
CS 1 with Robots Variables, Data Types & Math Institute for Personal Robots in Education (IPRE)‏ Sec 9-7 Web Design.
1 Chapter 9. To familiarize you with  Simple PERFORM  How PERFORM statements are used for iteration  Options available with PERFORM 2.
Control Structures RepetitionorIterationorLooping Part I.
 2002 Prentice Hall. All rights reserved. 1 Chapter 4 – Control Structures Part 1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures.
Counting Loops.
1 Printing in Python Every program needs to do some output This is usually to the screen (shell window) Later we’ll see graphics windows and external files.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 5: Control Structures II (Repetition)
Chapter 4 October 22, The If Statement Programs make decisions If(condition){ Statement(s); } Condition  boolean expression Evaluates to either.
Tutorial 6: The Repetition Structure1 Tutorial 6 The Repetition Structure.
5.1 Introduction Problem Solving –Requires understanding of: Building blocks Program-construction principles BZUPAGES.COM.
LECTURE # 8 : REPETITION STATEMENTS By Mr. Ali Edan.
 2002 Prentice Hall. All rights reserved. 1 Chapter 5 – Control Structures: Part 2 Outline 5.1Introduction 5.2 Essentials of Counter-Controlled Repetition.
Java Programming: From Problem Analysis to Program Design, 3e Chapter 5 Control Structures II: Repetition.
C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 5: Control Structures II (Repetition)
COMPUTER PROGRAMMING I 5.05 Apply Looping Structures.
Think Automation and beyond… FT1A Script Programming.
Operations with Integers PowerPoint Created By: Miss Henry.
An Introduction to Programming with C++ Sixth Edition Chapter 8 More on the Repetition Structure.
Programming Logic and Design Fourth Edition, Comprehensive
Addition of Signed Numbers
Goal: use counters to add integers
Loop Structures.
Chapter 4 – Control Structures Part 1
What two numbers will give you a product of 64 and a quotient of 4?
Java Programming Loops
Chapter (3) - Looping Questions.
Iteration: Beyond the Basic PERFORM
Unit 1 Day 2: Combining Like Terms Using Integers
Chapter 5: Control Structures II (Repetition)
Java Programming Loops
Integers.
L8-2 Notes: Adding Integers
What two numbers will give you a product of 64 and a quotient of 4?
How do I solve one-step equations
Presentation transcript:

Program variables Counters Accumulators Major and minor totals Control Click icon to hear comments (the download may take a minute )

Counters vs. Accumulators Counters usually change by a constant amount, such as +1 Counters can count down by subtracting Counters are almost always integers Accumulators usually increase by varying amounts, such as the amount of a sale Unlikely to ever subtract, but may be set to zero Data type often allows decimal (single or double precision)

Syntax Counter – studentCount = studentCount + 1 Accumulator – totalsales = totalsales + sales Notice that the variable name is repeated exactly on both sides of the equal sign Previous value is gone once a line is executed

Variable name reuse If a value might be needed later in the program, store it in a new variable before adding to it month1Sales = sales totalsales = totalsales + sales

Major and Minor totals “Major” refers to large group totals “Minor” refers to small group totals Examples – When totaling fund raising activity for students in a school, totals for students in a class would be considered minor totals. Totals for classes in the same grade would be stored in a major total. The total for the entire school might be called a grand total (a major total also).

Rolling totals For efficiency, add individual transactions to minor totals only. When the minor total for a group is complete, add it to the next higher level major total. Then set the minor total to zero, and re-use it to accumulate the total for the next group.

Where to use Counters – Number of records read – Number of lines printed – Number of errors – Successful/ unsuccessful attempts – Iterations of a loop Accumulators – Group totals – Total taxes – Total sales – Inventory value

Processing efficiency - summary Calculate summary average when needed using the value in the counters and accumulators (not for each transaction) Roll minor totals to major totals when processing groups of records Reset a variable and reuse it rather than creating a new variable when possible.

Controlling program flow Store status – Keep track of which actions have been completed – Store a beginning value for comparison or restore later Bread crumb path – Append or delete a value corresponding to hierarchy or flow Control flow on a branch – Use value to determine which branch of logic to follow – Use to indicate an action has been completed