Programming Language 2 (PL2)

Size: px
Start display at page:

Download "Programming Language 2 (PL2)"

Transcription

1 Programming Language 2 (PL2)

2 Illustrate the logical flow of program in sequence, selection and iteration structure Apply selection and repetitive structure

3 Repetition structure (or loop): a structure that repeatedly processes one or more program instructions until a condition is met Pretest loop The condition is evaluated before the instructions within the loop are processed The instructions may be processed zero or more times Posttest loop The condition is evaluated after the instructions within the loop are processed The instructions are always processed at least once

4 Repetition statements in Visual Basic Do...Loop For...Next For Each...Next

5 Do...Loop statement: codes both a pretest or posttest loop Use While or Until to code the condition for the loop Repetition symbol in a flowchart is the diamond

6 Figure 6-1: How to use the Do Loop statement

7 Figure 6-1: How to use the Do Loop statement (continued)

8 Figure 6-2: Processing steps for the pretest loop example

9 Figure 6-3: Processing steps for the posttest loop example

10 Figure 6-4: Pseudocode and flowchart for the pretest loop example

11 Figure 6-5: Pseudocode and flowchart for the posttest loop example

12 Figure 6-6: Examples showing that the pretest and posttest loops do not always produce the same results

13 Counter: a numeric variable used for counting Accumulator: a numeric variable used for accumulating (adding together) Initializing: assigning a beginning value to a counter or accumulator variable Updating (or incrementing): adding a number to the value of a counter or accumulator variable Counters are always incremented by a constant value, usually 1

14 Function: a predefined procedure that performs a specific task and returns a value InputBox function: displays a predefined dialog box that allows the user to enter data Contains a text message, an OK button, a Cancel button, and an input area InputBox function returns: The user s entry if the user clicks the OK button An empty string if the user clicks the Cancel button or the Close button on the title bar

15 Figure 6-7: Example of a dialog box created by the InputBox function

16 InputBox function parameters: prompt: the message to display inside the dialog box title: the text to display in the dialog box s title bar defaultresponse: a prefilled value for the user input

17 Figure 6-8: How to use the InputBox function

18 Figure 6-8: How to use the InputBox function (continued)

19 Requirements: display the average amount the company sold during the prior year Input: the amount of each salesperson s sales Priming read: used to obtain the first input Must verify that a variable does not contain the value 0 before using it as a divisor

20 Figure 6-9: Pseudocode for the Sales Express application

21 Figure 6-10: Sales Entry dialog box Figure 6-11: Average sales amount displayed in the interface

22 Figure 6-2: Code for the calcbutton in the Sales Express application

23 List box: displays a list of choices from which the user can select zero or more choices SelectionMode property: controls the number of choices a user can select None: user can scroll but not select anything One: user can select one item MultiSimple and MultiExtended: user can select multiple items

24 Items collection: a collection of the items in a list box Collection: a group of one or more individual objects treated as one unit Add method: adds an item to the list box s Items collection Items to be added must be converted to String Load event of a form: occurs when an application is started and the form is displayed for the first time

25 Figure 6-13: How to add items to a list box

26 Figure 6-14: Add methods entered in the form s Load event procedure

27 Sorted property: Determines if the list box items are sorted Sort order is dictionary order Figure 6-15: Items added to the animallistbox and codelistbox

28 Index: A unique number that identifies an item in a collection Is zero-relative: the first item has index of 0

29 Figure 6-16: How to access an item in a list box

30 Items.Count property: stores the number of items in a list box Count value is always one higher than the highest index in the list box

31 Figure 6-17: How to determine the number of items in a list box

32 SelectedItem property: Contains the value of the selected item in the list If nothing is selected, it contains the empty string SelectedIndex property: Contains the index of the selected item in the list If nothing is selected, it contains the value -1 Default list box item: the item that is selected by default when the interface first appears

33 Figure 6-18: Item selected in the animallistbox

34 Figure 6-19: How to use the SelectedItem and SelectedIndex properties

35 Figure 6-20: How to select the default list box item

36 Figure 6-21: Code to select the default item in each list box

37 SelectedValueChanged and SelectedIndexChanged events: Occur when a user selects an item in a list box Occur when a code statement selects an item in a list box

38 Figure 6-22: SelectedValueChanged and SelectedIndexChanged event procedures

39 Figure 6-23: Result of processing the SelectedValueChanged and SelectedIndexChanged event procedures

40 Allows the user to enter a product ID Searches for the ID in a list box If found, highlights the ID

41 Figure 6-24: Pseudocode for the Product Finder application

42 Figure 6-25: Sample run of the application when an ID is found Figure 6-26: Sample run of the application when an ID is not found

43 Figure 6-27: Code for the form s Load event and findbutton s Click event procedures

44 For...Next statement: processes a set of instructions a known number of times Is a pretest loop Counter variable: used to keep track of the number of times the loop has been processed Startvalue, endvalue, and stepvalue items Control the number of times the loop is processed Must evaluate to numeric values Can be positive or negative A negative stepvalue causes the loop counter to count down

45 Figure 7-1: How to use the For Next statement

46 Figure 7-2: Processing tasks for the For Next statement

47 Figure 7-3: Processing steps for the code shown in Example 1

48 Flowchart symbol for the For...Next loop is a hexagon Values for the counter variable, startvalue, stepvalue, and endvalue are shown within the hexagon

49 Figure 7-4: Pseudocode and flowchart for Example 1

50 Financial.Pmt method Calculates a periodic payment on a loan or investment Returns the periodic payment as a Double type value Rate and number of periods arguments must be expressed in the same units (monthly, annual, etc.) Also calculates the amount that must be saved each period to accumulate a specific sum

51 Figure 7-5: How to use the Financial.Pmt method

52 Figure 7-5: Sample run of the Monthly Payment Calculator application

53 Figure 7-7: Two procedures in the Monthly Payment Calculator application

54 Figure 7-7: Two procedures in the Monthly Payment Calculator application (continued)

55 Windows standard: highlight the existing text when a text box receives the focus SelectAll method: selects all text in a text box Enter event: occurs when the text box receives the focus

56 Figure 7-8: How to select the existing text in a text box

57 Figure 7-9: The principaltextbox s Enter event procedure Figure 7-10: Result of processing the Enter event procedure

58 TextChanged event Occurs when a change is made in a control s Text property Change may be made by user or the program Figure 7-11: New principal entered in the Principal text box

59 Figure 7-12: The principaltextbox s TextChanged event procedure Figure 7-13: Status of the paymentslabel after entering a value in the text box

60 Figure 7-14: The termlistbox s SelectedValueChanged event procedure

61 Combo Box control: Similar to a list box with a list of choices May contain a text field that allows the user to type an entry that is not on the list List portion may be hidden Three styles of combo boxes: Simple DropDown (the default) DropDownList

62 Figure 7-15: Examples of the combo box styles

63 Figure 7-15: Code used to fill the combo boxes with values

64 Items.Add method: used to add items to a combo box SelectedItem property: contains the value of the selected item in the list Text property: contains the value that appears in the text portion of the control (item selected or typed in) Items.count property: used to obtain the number of items in the combo box Sorted property: used to sort the items in the list

65 Figure 7-17: Sample run of the Monthly Payment Calculator application using a combo box

66 Figure 7-15a: Code for the Monthly Payment Calculator using a combo box

67 Figure 7-15b: Code for the Monthly Payment Calculator using a combo box

68 Most applications need to manipulate string data in some fashion String properties and methods are used to manipulate string data

69 Figure 7-19a: How to use the Length property

70 Figure 7-19b: How to use the Length property

71 TrimStart method: removes one or more characters from the beginning of a string TrimEnd method: removes one or more characters from the end of a string Trim method: removes one or more characters from both the beginning and end of a string Each of these methods returns a string with the appropriate characters removed trimchars argument: Comma-separated list of characters to be removed If omitted, spaces will be removed Default value is the space character:

72 Figure 7-20: How to use the TrimStart, TrimEnd, and Trim methods

73 Remove method: Removes characters from a string Can remove one or more characters located anywhere in the string Returns a string with the appropriate characters removed startindex argument: The position of a character in a string Is zero-relative (starts with 0 as first position) count argument: number of characters to remove

74 Figure 7-21: How to use the Remove method

75 Replace method: replaces a sequence of characters in a string with another sequence of characters Arguments: string: the original String value oldvalue: sequence of characters you want to replace newvalue: replacement characters

76 Figure 7-22: How to use the Replace method

77 Mid statement: Replaces a specified number of characters in a string with characters from another string Arguments: targetstring: the string in which characters are to be replaced replacementstring: the replacement characters start: the starting position for the replacement count: number of characters to replace

78 Character position of characters in the string starts with 1 (not the same as index) Count argument is optional

79 Figure 7-23: How to use the Mid statement

80 PadLeft method: inserts characters at the beginning of a string PadRight method: inserts characters at the end of a string Arguments: length: represents the total length of the desired resulting string character: the character used to pad the string; default value is the space character string: the string on which the operation takes place

81 Figure 7-24: How to use the PadLeft and PadRight methods

82 Insert method: used to insert characters anywhere within a string Arguments: startindex: specifies where in the string to insert the value string: the string being manipulated value: the character(s) to be inserted

83 Figure 7-25: How to use the Insert method

84 StartsWith method: determines whether a specific sequence of characters occurs at the beginning of a string EndsWith method: determines whether a specific sequence of characters occurs at the end of a string Arguments: substring: sequence of characters to be searched for StartsWith and EndsWith methods both return Boolean values and perform a casesensitive search

85 Figure 7-26: How to use the StartsWith and EndsWith methods

86 Figure 7-26: How to use the StartsWith and EndsWith methods (continued)

87 Contains method: Determines if a string contains a specific sequence of characters Is a method of the String class Returns a Boolean value Performs a case-sensitive search Arguments: substring: represents the sequence of characters to be searched for string: the string in which to search

88 Figure 7-27: How to use the Contains method

89 IndexOf method: returns an integer representing the location of a substring within a string Performs a case-sensitive search Arguments: substring: sequence of characters to be searched for string: the string to be searched startindex: the starting position for the search (zero-relative)

90 Figure 7-28: How to use the IndexOf method

91 Substring method: accesses any number of characters contained in a string Arguments: startindex: index of the first character to be accessed (zero-relative) string: the string containing the characters to be accessed count: number of characters to be accessed

92 Figure 7-29: How to use the Substring method

93 String.Compare method: compares two strings Arguments: string1, string2: the two strings to be compared ignorecase: a Boolean value indicating whether to perform a case-sensitive (False) or caseinsensitive (True) search

94 String.Compare returns an integer result: Returns 0 when string1 equals string2 Returns 1 when string1 > string2 Returns -1 when string1 < string2 String.Compare uses word sort rules: Numbers are less than lowercase letters Lowercase letters are less than uppercase letters

95 Figure 7-30: How to use the String.Compare method

96 Like operator: Uses pattern-matching characters to determine if one string is equal to another Returns a Boolean value (True/False) Arguments: pattern: contains one or more pattern-matching characters string: the string to be evaluated charlist: a listing of characters to be matched

97 Figure 7-31: How to use the Like operator

98 Figure 7-31: How to use the Like operator (continued)

99 Creating the Roll Em Game Sleep method: delays execution of the program Refresh method: redraws the user interface Figure 6-29: User interface

100 Grade Calculator Figure 6-43: User interface

101 Creating the Hangman Game Figure 7-33: User interface

102 Principal and Interest Calculator Figure 7-46: User interface

Microsoft Visual Basic 2005: Reloaded

Microsoft Visual Basic 2005: Reloaded Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 5 Repeating Program Instructions Objectives After studying this chapter, you should be able to: Include the repetition structure in pseudocode

More information

Microsoft Visual Basic 2015: Reloaded

Microsoft Visual Basic 2015: Reloaded Microsoft Visual Basic 2015: Reloaded Sixth Edition Chapter Seven More on the Repetition Structure Objectives After studying this chapter, you should be able to: Code a counter-controlled loop Nest repetition

More information

Copyright 2014 Pearson Education, Inc. Chapter 5. Lists and Loops. Copyright 2014 Pearson Education, Inc.

Copyright 2014 Pearson Education, Inc. Chapter 5. Lists and Loops. Copyright 2014 Pearson Education, Inc. Chapter 5 Lists and Loops Topics 5.1 Input Boxes 5.2 List Boxes 5.3 Introduction to Loops: The Do While Loop 5.4 The Do Until and For Next Loops 5.5 Nested Loops 5.6 Multicolumn List Boxes, Checked List

More information

An Introduction to Programming with C++ Sixth Edition. Chapter 7 The Repetition Structure

An Introduction to Programming with C++ Sixth Edition. Chapter 7 The Repetition Structure An Introduction to Programming with C++ Sixth Edition Chapter 7 The Repetition Structure Objectives Differentiate between a pretest loop and a posttest loop Include a pretest loop in pseudocode Include

More information

Chapter 2B: Lists and Loops

Chapter 2B: Lists and Loops Chapter 2B: Lists and Loops Introduction This chapter introduces: Input boxes List and combo boxes Loops Random numbers The ToolTip control Section 2B.1 Input Boxes Input boxes provide a simple way to

More information

Chapter 5. Lists and Loops Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of

Chapter 5. Lists and Loops Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Chapter 5 Lists and Loops Addison Wesley is an imprint of 2011 Pearson Addison-Wesley. All rights reserved. Introduction This chapter introduces: Input boxes List and combo boxes Loops Random numbers The

More information

used for US Census; Holes were made to represent information to be tabulated were punched in cards; Successful

used for US Census; Holes were made to represent information to be tabulated were punched in cards; Successful Essential Standard: 1.00 Understand ethics, security and the history of computer programming Indicator 1.01 Understand the evolution of computers and computer programming languages Indicator 1.02 Understand

More information

Chapter Ten String Manipulation and Menus

Chapter Ten String Manipulation and Menus Microsoft Visual Basic 2015: Reloaded Sixth Edition Chapter Ten String Manipulation and Menus Objectives After studying this chapter, you should be able to: Determine the number of characters in a string

More information

Repetition Structures

Repetition Structures Repetition Structures Chapter 5 Fall 2016, CSUS Introduction to Repetition Structures Chapter 5.1 1 Introduction to Repetition Structures A repetition structure causes a statement or set of statements

More information

Condition-Controlled Loop. Condition-Controlled Loop. If Statement. Various Forms. Conditional-Controlled Loop. Loop Caution.

Condition-Controlled Loop. Condition-Controlled Loop. If Statement. Various Forms. Conditional-Controlled Loop. Loop Caution. Repetition Structures Introduction to Repetition Structures Chapter 5 Spring 2016, CSUS Chapter 5.1 Introduction to Repetition Structures The Problems with Duplicate Code A repetition structure causes

More information

Repetition Structures

Repetition Structures Repetition Structures There are three main structures used in programming: sequential, decision and repetition structures. Sequential structures follow one line of code after another. Decision structures

More information

An Introduction to Programming with C++ Sixth Edition. Chapter 8 More on the Repetition Structure

An Introduction to Programming with C++ Sixth Edition. Chapter 8 More on the Repetition Structure An Introduction to Programming with C++ Sixth Edition Chapter 8 More on the Repetition Structure Objectives Include a posttest loop in pseudocode Include a posttest loop in a flowchart Code a posttest

More information

Chapter 7. Lists, Loops, and Printing The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill

Chapter 7. Lists, Loops, and Printing The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Chapter 7 Lists, Loops, and Printing McGraw-Hill 2010 The McGraw-Hill Companies, Inc. All rights reserved. Chapter Objectives - 1 Create and use list boxes and combo boxes Differentiate among the available

More information

A Beginner s Guide to Programming Logic, Introductory. Chapter 5 Looping

A Beginner s Guide to Programming Logic, Introductory. Chapter 5 Looping A Beginner s Guide to Programming Logic, Introductory Chapter 5 Looping Objectives In this chapter, you will learn about: The advantages of looping Using a loop control variable Nested loops Avoiding common

More information

REPETITION CONTROL STRUCTURE LOGO

REPETITION CONTROL STRUCTURE LOGO CSC 128: FUNDAMENTALS OF COMPUTER PROBLEM SOLVING REPETITION CONTROL STRUCTURE 1 Contents 1 Introduction 2 for loop 3 while loop 4 do while loop 2 Introduction It is used when a statement or a block of

More information

You will have mastered the material in this chapter when you can:

You will have mastered the material in this chapter when you can: CHAPTER 6 Loop Structures OBJECTIVES You will have mastered the material in this chapter when you can: Add a MenuStrip object Use the InputBox function Display data using the ListBox object Understand

More information

Microsoft Visual Basic 2005 CHAPTER 6. Loop Structures

Microsoft Visual Basic 2005 CHAPTER 6. Loop Structures Microsoft Visual Basic 2005 CHAPTER 6 Loop Structures Objectives Add a MenuStrip object Use the InputBox function Display data using the ListBox object Understand the use of counters and accumulators Understand

More information

Excel 2007 Intermediate Table of Contents

Excel 2007 Intermediate Table of Contents Table of Contents Working with Data... 1 Subtotals... 1 Removing Subtotals... 2 Grouping Columns or Rows... 2 Ungrouping Data... 3 AutoCalculate Customize Status Bar... 3 Format as Table Filters and Sorting...

More information

Assoc. Prof. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Assoc. Prof. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved. Assoc. Prof. Marenglen Biba (C) 2010 Pearson Education, Inc. All This chapter discusses class String, from the java.lang package. These classes provide the foundation for string and character manipulation

More information

Lecture 7 Tao Wang 1

Lecture 7 Tao Wang 1 Lecture 7 Tao Wang 1 Objectives In this chapter, you will learn about: Interactive loop break and continue do-while for loop Common programming errors Scientists, Third Edition 2 while Loops while statement

More information

Final Examination Semester 2 / Year 2010

Final Examination Semester 2 / Year 2010 Southern College Kolej Selatan 南方学院 Final Examination Semester 2 / Year 2010 COURSE : VISUAL BASIC.NET COURSE CODE : PROG2024 TIME : 2 1/2 HOURS DEPARTMENT : COMPUTER SCIENCE LECTURER : LIM PEI GEOK Student

More information

Chapter 7. Lists, Loops, and Printing. McGraw-Hill. Copyright 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved.

Chapter 7. Lists, Loops, and Printing. McGraw-Hill. Copyright 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. Chapter 7 Lists, Loops, and Printing McGraw-Hill Copyright 2011 by The McGraw-Hill Companies, Inc. All Rights Reserved. Objectives (1 of 2) Create and use list boxes and combo boxes. Differentiate among

More information

Computer Programming I - Unit 5 Lecture page 1 of 14

Computer Programming I - Unit 5 Lecture page 1 of 14 page 1 of 14 I. The while Statement while, for, do Loops Note: Loop - a control structure that causes a sequence of statement(s) to be executed repeatedly. The while statement is one of three looping statements

More information

Assoc. Prof. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Assoc. Prof. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved. Assoc. Prof. Marenglen Biba (C) 2010 Pearson Education, Inc. All Advanced Java This chapter discusses class String, class StringBuilder and class Character from the java.lang package. These classes provide

More information

Searching and Strings. IST 256 Application Programming for Information Systems

Searching and Strings. IST 256 Application Programming for Information Systems Searching and Strings IST 256 Application Programming for Information Systems Searching for Strings In an array, we do a simple linear search for an item by going through the array in order from the first

More information

Definition: A data structure is a way of organizing data in a computer so that it can be used efficiently.

Definition: A data structure is a way of organizing data in a computer so that it can be used efficiently. The Science of Computing I Lesson 4: Introduction to Data Structures Living with Cyber Pillar: Data Structures The need for data structures The algorithms we design to solve problems rarely do so without

More information

5.1. Chapter 5: The Increment and Decrement Operators. The Increment and Decrement Operators. Looping. ++ is the increment operator.

5.1. Chapter 5: The Increment and Decrement Operators. The Increment and Decrement Operators. Looping. ++ is the increment operator. Chapter 5: Looping 5.1 The Increment and Decrement Operators Copyright 2009 Pearson Education, Inc. Copyright Publishing as Pearson 2009 Addison-Wesley Pearson Education, Inc. Publishing as Pearson Addison-Wesley

More information

*Starting Out with C++: From Control Structures through Objects, 7/E* by *Tony Gaddis* COMPUTER PROGRAMMING LECTURE 05 LOOPS IMRAN IHSAN

*Starting Out with C++: From Control Structures through Objects, 7/E* by *Tony Gaddis* COMPUTER PROGRAMMING LECTURE 05 LOOPS IMRAN IHSAN PowerPoint Slides adapted from *Starting Out with C++: From Control Structures through Objects, 7/E* by *Tony Gaddis* Copyright 2012 Pearson Education Inc. COMPUTER PROGRAMMING LECTURE 05 LOOPS IMRAN IHSAN

More information

Contents. More Controls 51. Visual Basic 1. Introduction to. xiii. Modify the Project 30. Print the Project Documentation 35

Contents. More Controls 51. Visual Basic 1. Introduction to. xiii. Modify the Project 30. Print the Project Documentation 35 Contents Modify the Project 30 Introduction to Print the Project Documentation 35 Visual Basic 1 Sample Printout 36 Writing Windows Applications The Form Image 36 The Code 37 with Visual Basic 2 The Form

More information

Formulas, LookUp Tables and PivotTables Prepared for Aero Controlex

Formulas, LookUp Tables and PivotTables Prepared for Aero Controlex Basic Topics: Formulas, LookUp Tables and PivotTables Prepared for Aero Controlex Review ribbon terminology such as tabs, groups and commands Navigate a worksheet, workbook, and multiple workbooks Prepare

More information

PROBLEM SOLVING WITH LOOPS. Chapter 7

PROBLEM SOLVING WITH LOOPS. Chapter 7 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 many times. Ex. The Process of calculating the Total

More information

Microsoft Visual Basic 2005: Reloaded

Microsoft Visual Basic 2005: Reloaded Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 4 Making Decisions in a Program Objectives After studying this chapter, you should be able to: Include the selection structure in pseudocode

More information

Microsoft Office Excel Use Excel s functions. Tutorial 2 Working With Formulas and Functions

Microsoft Office Excel Use Excel s functions. Tutorial 2 Working With Formulas and Functions Microsoft Office Excel 2003 Tutorial 2 Working With Formulas and Functions 1 Use Excel s functions You can easily calculate the sum of a large number of cells by using a function. A function is a predefined,

More information

ECE 122. Engineering Problem Solving with Java

ECE 122. Engineering Problem Solving with Java ECE 122 Engineering Problem Solving with Java Lecture 10 For Loops and Arrays Outline Problem: How can I perform the same operations a fixed number of times? Considering for loops Performs same operations

More information

Excel Intermediate. Click in the name column of our Range of Data. (Do not highlight the column) Click on the Data Tab in the Ribbon

Excel Intermediate. Click in the name column of our Range of Data. (Do not highlight the column) Click on the Data Tab in the Ribbon Custom Sorting and Subtotaling Excel Intermediate Excel allows us to sort data whether it is alphabetic or numeric. Simply clicking within a column or row of data will begin the process. Click in the name

More information

Working with Data and Charts

Working with Data and Charts PART 9 Working with Data and Charts In Excel, a formula calculates a value based on the values in other cells of the workbook. Excel displays the result of a formula in a cell as a numeric value. A function

More information

Test #2 October 8, 2015

Test #2 October 8, 2015 CPSC 1040 Name: Test #2 October 8, 2015 Closed notes, closed laptop, calculators OK. Please use a pencil. 100 points, 5 point bonus. Maximum score 105. Weight of each section in parentheses. If you need

More information

PIC 40A. Lecture 10: JS: Wrapper objects, Input and Output, Control structures, random numbers. Copyright 2011 Jukka Virtanen UCLA 1 04/24/17

PIC 40A. Lecture 10: JS: Wrapper objects, Input and Output, Control structures, random numbers. Copyright 2011 Jukka Virtanen UCLA 1 04/24/17 PIC 40A Lecture 10: JS: Wrapper objects, Input and Output, Control structures, random numbers 04/24/17 Copyright 2011 Jukka Virtanen UCLA 1 Objects in JS In C++ we have classes, in JS we have OBJECTS.

More information

Arrays, Strings and Collections

Arrays, Strings and Collections Arrays Arrays can be informally defined as a group of variables containing values of the same type and that in some way or another they are related. An array has a fixed size that is defined before the

More information

M i c r o s o f t E x c e l A d v a n c e d P a r t 3-4. Microsoft Excel Advanced 3-4

M i c r o s o f t E x c e l A d v a n c e d P a r t 3-4. Microsoft Excel Advanced 3-4 Microsoft Excel 2010 Advanced 3-4 0 Absolute references There may be times when you do not want a cell reference to change when copying or filling cells. You can use an absolute reference to keep a row

More information

Indicate the answer choice that best completes the statement or answers the question. Enter the appropriate word(s) to complete the statement.

Indicate the answer choice that best completes the statement or answers the question. Enter the appropriate word(s) to complete the statement. 1. C#, C++, C, and Java use the symbol as the logical OR operator. a. $ b. % c. ^ d. 2. errors are relatively easy to locate and correct because the compiler or interpreter you use highlights every error.

More information

Increment and the While. Class 15

Increment and the While. Class 15 Increment and the While Class 15 Increment and Decrement Operators Increment and Decrement Increase or decrease a value by one, respectively. the most common operation in all of programming is to increment

More information

Philadelphia University Faculty of Information Technology. Visual Programming

Philadelphia University Faculty of Information Technology. Visual Programming Philadelphia University Faculty of Information Technology Visual Programming Using C# -Work Sheets- Prepared by: Dareen Hamoudeh Eman Al Naji Work Sheet 1 Form, Buttons and labels Properties Changing properties

More information

Chapter 6 Repetition. 6.1 Do Loops 6.2 For...Next Loops 6.3 List Boxes and Loops

Chapter 6 Repetition. 6.1 Do Loops 6.2 For...Next Loops 6.3 List Boxes and Loops Chapter 6 Repetition 6.1 Do Loops 6.2 For...Next Loops 6.3 List Boxes and Loops 1 6.1 Do Loops Pretest Form of a Do Loop Posttest Form of a Do Loop 2 Do Loops A loop is one of the most important structures

More information

Skill Area 306: Develop and Implement Computer Program

Skill Area 306: Develop and Implement Computer Program Add your company slogan Skill Area 306: Develop and Implement Computer Program Computer Programming (YPG) LOGO Skill Area 306.2: Produce Structured Program 306.2.1 Write Algorithm 306.2.2 Apply appropriate

More information

Report Writing: Basic Steps

Report Writing: Basic Steps Report Writing: Basic Steps Working with Reports The Research Wizard allows you to create multi-company reports that combine Zacks database items and your own calculated items. The Research Wizard also

More information

Loops / Repetition Statements

Loops / Repetition Statements Loops / Repetition Statements Repetition statements allow us to execute a statement multiple times Often they are referred to as loops C has three kinds of repetition statements: the while loop the for

More information

Excel Tips. Contents. By Dick Evans

Excel Tips. Contents. By Dick Evans Excel Tips By Dick Evans Contents Pasting Data into an Excel Worksheet... 2 Divide by Zero Errors... 2 Creating a Dropdown List... 2 Using the Built In Dropdown List... 3 Entering Data with Forms... 4

More information

Unit 7. Lesson 7.1. Loop. For Next Statements. Introduction. Loop

Unit 7. Lesson 7.1. Loop. For Next Statements. Introduction. Loop Loop Unit 7 Loop Introduction So far we have seen that each instruction is executed once and once only. Some time we may require that a group of instructions be executed repeatedly, until some logical

More information

Loops! Loops! Loops! Lecture 5 COP 3014 Fall September 25, 2017

Loops! Loops! Loops! Lecture 5 COP 3014 Fall September 25, 2017 Loops! Loops! Loops! Lecture 5 COP 3014 Fall 2017 September 25, 2017 Repetition Statements Repetition statements are called loops, and are used to repeat the same code mulitple times in succession. The

More information

CS112 Lecture: Repetition Statements

CS112 Lecture: Repetition Statements CS112 Lecture: Repetition Statements Objectives: Last revised 2/18/05 1. To explain the general form of the java while loop 2. To introduce and motivate the java do.. while loop 3. To explain the general

More information

Looping Subtasks. We will examine some basic algorithms that use the while and if constructs. These subtasks include

Looping Subtasks. We will examine some basic algorithms that use the while and if constructs. These subtasks include 1 Programming in C Looping Subtasks We will examine some basic algorithms that use the while and if constructs. These subtasks include Reading unknown quantity of data Counting things Accumulating (summing)

More information

Multiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)

Multiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible) Name Closed notes, book and neighbor. If you have any questions ask them. Notes: Segment of code necessary C++ statements to perform the action described not a complete program Program a complete C++ program

More information

Java Programming: Guided Learning with Early Objects Chapter 5 Control Structures II: Repetition

Java Programming: Guided Learning with Early Objects Chapter 5 Control Structures II: Repetition Java Programming: Guided Learning with Early Objects Chapter 5 Control Structures II: Repetition Learn about repetition (looping) control structures Explore how to construct and use: o Counter-controlled

More information

Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 5-1

Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 5-1 Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide 5-1 Chapter 6 : (Control Structure- Repetition) Using Decrement or Increment While Loop Do-While Loop FOR Loop Nested Loop

More information

Page 1 of 14 Version A Midterm Review 1. The sign means greater than. > =

More information

Create formulas in Excel

Create formulas in Excel Training Create formulas in Excel EXERCISE 1: TYPE SOME SIMPLE FORMULAS TO ADD, SUBTRACT, MULTIPLY, AND DIVIDE 1. Click in cell A1. First you ll add two numbers. 2. Type =534+382. 3. Press ENTER on your

More information

Looping. Arizona State University 1

Looping. Arizona State University 1 Looping CSE100 Principles of Programming with C++, Fall 2018 (based off Chapter 5 slides by Pearson) Ryan Dougherty Arizona State University http://www.public.asu.edu/~redoughe/ Arizona State University

More information

Full file at Excel Chapter 2 - Formulas, Functions, Formatting, and Web Queries

Full file at   Excel Chapter 2 - Formulas, Functions, Formatting, and Web Queries Excel Chapter 2 - Formulas, Functions, Formatting, and Web Queries MULTIPLE CHOICE 1. To start a new line in a cell, press after each line, except for the last line, which is completed by clicking the

More information

Condition Controlled Loops. Introduction to Programming - Python

Condition Controlled Loops. Introduction to Programming - Python + Condition Controlled Loops Introduction to Programming - Python + Repetition Structures n Programmers commonly find that they need to write code that performs the same task over and over again + Example:

More information

Chapter 5: Prefix vs. Postfix 8/19/2018. The Increment and Decrement Operators. Increment and Decrement Operators in Program 5-1

Chapter 5: Prefix vs. Postfix 8/19/2018. The Increment and Decrement Operators. Increment and Decrement Operators in Program 5-1 Chapter 5: Loops and Files The Increment and Decrement Operators ++ is the increment operator. It adds one to a variable. val++; is the same as val = val + 1; ++ can be used before (prefix) or after (postfix)

More information

Excel Intermediate

Excel Intermediate Excel 2013 - Intermediate (103-124) Advanced Functions Quick Links Range Names Pages EX394 EX407 Data Validation Pages EX410 EX419 VLOOKUP Pages EX176 EX179 EX489 EX500 IF Pages EX172 EX176 EX466 EX489

More information

BCS THE CHARTERED INSTITUTE FOR IT. BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 4 Certificate in IT SOFTWARE DEVELOPMENT

BCS THE CHARTERED INSTITUTE FOR IT. BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 4 Certificate in IT SOFTWARE DEVELOPMENT BCS THE CHARTERED INSTITUTE FOR IT BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 4 Certificate in IT SOFTWARE DEVELOPMENT Wednesday 25th March 2015 - Afternoon Time: TWO hours Section A and Section B each

More information

LAB: WHILE LOOPS IN C++

LAB: WHILE LOOPS IN C++ LAB: WHILE LOOPS IN C++ MODULE 2 JEFFREY A. STONE and TRICIA K. CLARK COPYRIGHT 2014 VERSION 4.0 PALMS MODULE 2 LAB: WHILE LOOPS IN C++ 2 Introduction This lab will provide students with an introduction

More information

PLD Semester Exam Study Guide Dec. 2018

PLD Semester Exam Study Guide Dec. 2018 Covers material from Chapters 1-8. Semester Exam will be built from these questions and answers, though they will be re-ordered and re-numbered and possibly worded slightly differently than on this study

More information

5.1. Chapter 5: The Increment and Decrement Operators. The Increment and Decrement Operators. The Increment and Decrement Operators

5.1. Chapter 5: The Increment and Decrement Operators. The Increment and Decrement Operators. The Increment and Decrement Operators Chapter 5: 5.1 Looping The Increment and Decrement Operators The Increment and Decrement Operators The Increment and Decrement Operators ++ is the increment operator. It adds one to a variable. val++;

More information

Iteration: Intro. Two types of loops: 1. Pretest Condition precedes body Iterates 0+ times. 2. Posttest Condition follows body Iterates 1+ times

Iteration: Intro. Two types of loops: 1. Pretest Condition precedes body Iterates 0+ times. 2. Posttest Condition follows body Iterates 1+ times Iteration: Intro Two types of loops: 1. Pretest Condition precedes body Iterates 0+ times 2. Posttest Condition follows body Iterates 1+ times 1 Iteration: While Loops Pretest loop Most general loop construct

More information

Higher Computing Science Software Design and Development - Programming Summary Notes

Higher Computing Science Software Design and Development - Programming Summary Notes Higher Computing Science Software Design and Development - Programming Summary Notes Design notations A design notation is the method we use to write down our program design. Pseudocode is written using

More information

Superior University. Department of Electrical Engineering CS-115. Computing Fundamentals. Experiment No.5. for loop and do-while loop

Superior University. Department of Electrical Engineering CS-115. Computing Fundamentals. Experiment No.5. for loop and do-while loop Superior University Department of Electrical Engineering CS-115 Computing Fundamentals Experiment No.5 for loop and do-while loop Prepared for By: Name: ID: Section: Semester: Total Marks: Obtained Marks:

More information

There are algorithms, however, that need to execute statements in some other kind of ordering depending on certain conditions.

There are algorithms, however, that need to execute statements in some other kind of ordering depending on certain conditions. Introduction In the programs that we have dealt with so far, all statements inside the main function were executed in sequence as they appeared, one after the other. This type of sequencing is adequate

More information

Introduction to Functions and Variables

Introduction to Functions and Variables Introduction to Functions and Variables Functions are a way to add additional elements into your OBI Report. They enable you to manipulate data, perform computations and comparisons, and get system information.

More information

C++ Quick Reference. switch Statements

C++ Quick Reference. switch Statements C++ Quick Reference if Statements switch Statements Array/Initializer if (condition) if (condition) else if (condition1) else if (condition2) else Loop Statements while (condition) do while (condition);

More information

Advisor Workstation Training Manual: Working in the Research Module

Advisor Workstation Training Manual: Working in the Research Module Advisor Workstation Training Manual: Working in the Research Module Overview of the Research module - - - - - - - - - - - - - - - - 1 What you will learn in this section - - - - - - - - - - - - - - - -

More information

Programming in C++ PART 2

Programming in C++ PART 2 Lecture 07-2 Programming in C++ PART 2 By Assistant Professor Dr. Ali Kattan 1 The while Loop and do..while loop In the previous lecture we studied the for Loop in C++. In this lecture we will cover iteration

More information

Flag Quiz Application

Flag Quiz Application T U T O R I A L 17 Objectives In this tutorial, you will learn to: Create and initialize arrays. Store information in an array. Refer to individual elements of an array. Sort arrays. Use ComboBoxes to

More information

Fundamentals of Programming Session 13

Fundamentals of Programming Session 13 Fundamentals of Programming Session 13 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Fall 2014 These slides have been created using Deitel s slides Sharif University of Technology Outlines

More information

Chapter 5 : Repetition (pp )

Chapter 5 : Repetition (pp ) Page 1 of 41 Printer Friendly Version User Name: Stephen Castleberry email Id: scastleberry@rivercityscience.org Book: A First Book of C++ 2007 Cengage Learning Inc. All rights reserved. No part of this

More information

Excel. Tutorial 1 Getting Started with Excel. Tutorial 2 Formatting a Workbook. Tutorial 3 Working with Formulas and Functions COMPREHENSIVE

Excel. Tutorial 1 Getting Started with Excel. Tutorial 2 Formatting a Workbook. Tutorial 3 Working with Formulas and Functions COMPREHENSIVE Excel Tutorial 1 Getting Started with Excel Tutorial 2 Formatting a Workbook Tutorial 3 Working with Formulas and Functions COMPREHENSIVE Excel Tutorial 1 Getting Started with Excel COMPREHENSIVE Objectives

More information

Chapter 4 Lab. Loops and Files. Objectives. Introduction

Chapter 4 Lab. Loops and Files. Objectives. Introduction Chapter 4 Lab Loops and Files Objectives Be able to convert an algorithm using control structures into Java Be able to write a while loop Be able to write a do-while loop Be able to write a for loop Be

More information

Repetition Algorithms

Repetition Algorithms Repetition Algorithms Repetition Allows a program to execute a set of instructions over and over. The term loop is a synonym for a repetition statement. A Repetition Example Suppose that you have been

More information

Chapter 3. More Flow of Control. Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Chapter 3. More Flow of Control. Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 More Flow of Control Overview 3.1 Using Boolean Expressions 3.2 Multiway Branches 3.3 More about C++ Loop Statements 3.4 Designing Loops Slide 3-3 Flow Of Control Flow of control refers to the

More information

Programming. C# Programming: From Problem Analysis to Program Design 2nd Edition. David McDonald, Ph.D. Director of Emerging Technologies

Programming. C# Programming: From Problem Analysis to Program Design 2nd Edition. David McDonald, Ph.D. Director of Emerging Technologies 9 Programming Based on Events C# Programming: From Problem Analysis to Program Design 2nd Edition David McDonald, Ph.D. Director of Emerging Technologies Chapter Objectives Create applications that use

More information

Introductory Mobile Application Development

Introductory Mobile Application Development Notes Quick Links Introductory Mobile Application Development 152-160 Java Syntax Part 2 - Activity String Class Add section on Parse ArrayList Class methods. Book page 95. Toast Page 129 240 242 String

More information

Approved Association Invoices

Approved Association Invoices Approved Association Invoices Approved Association Invoices 1 Invoices 2 New Membership Dues Form 3 Invoice and Payment Form 5 Renewal Dues Form 9 Renewal Dues Batch Form 11 Event Registration Form 14

More information

Working with Formulas and Functions

Working with Formulas and Functions Microsoft Excel 20032003- Illustrated Introductory Working with Formulas and Functions Objectives Create a formula with several operators Use names in a formula Generate multiple totals with AutoSum Use

More information

Iteration Loops. The Do While Loop (Continued) Looping Subtasks

Iteration Loops. The Do While Loop (Continued) Looping Subtasks Iteration s The Do While (Continued) ing Subtasks This section in your book is from pages 2 to. You might think that, since this in the Do While loop section, it only refers to those kinds of loops. This

More information

Chapter 4 C Program Control

Chapter 4 C Program Control 1 Chapter 4 C Program Control Copyright 2007 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 2 Chapter 4 C Program Control Outline 4.1 Introduction 4.2 The Essentials of Repetition

More information

Individual research task. You should all have completed the research task set last week. Please make sure you hand it in today.

Individual research task. You should all have completed the research task set last week. Please make sure you hand it in today. Lecture 6 Individual research task. You should all have completed the research task set last week. Please make sure you hand it in today. Previously Decision structures with flowcharts Boolean logic UML

More information

Programming Language. Control Structures: Repetition (while) Eng. Anis Nazer Second Semester

Programming Language. Control Structures: Repetition (while) Eng. Anis Nazer Second Semester Programming Language Control Structures: Repetition (while) Eng. Anis Nazer Second Semester 2017-2018 Repetition statements Control statements change the order which statements are executed Selection :

More information

EVALUATION COPY. Unauthorized Reproduction or Distribution Prohibited

EVALUATION COPY. Unauthorized Reproduction or Distribution Prohibited INTERMEDIATE MICROSOFT EXCEL 2016 Intermediate Microsoft Excel 2016 (EXC2016.2 version 1.0.1) Copyright Information Copyright 2016 Webucator. All rights reserved. The Authors Dave Dunn Dave Dunn joined

More information

CS112 Lecture: Loops

CS112 Lecture: Loops CS112 Lecture: Loops Objectives: Last revised 3/11/08 1. To introduce some while loop patterns 2. To introduce and motivate the java do.. while loop 3. To review the general form of the java for loop.

More information

Pivot Tables, Lookup Tables and Scenarios

Pivot Tables, Lookup Tables and Scenarios Introduction Format and manipulate data using pivot tables. Using a grading sheet as and example you will be shown how to set up and use lookup tables and scenarios. Contents Introduction Contents Pivot

More information

Programming for Engineers Iteration

Programming for Engineers Iteration Programming for Engineers Iteration ICEN 200 Spring 2018 Prof. Dola Saha 1 Data type conversions Grade average example,-./0 class average = 23450-67 893/0298 Grade and number of students can be integers

More information

Repetition. Chapter 6

Repetition. Chapter 6 Chapter 6 Repetition Goals This chapter introduces the third major control structure repetition (sequential and selection being the first two). Repetition is discussed within the context of two general

More information

Introduction to C Programming

Introduction to C Programming 1 2 Introduction to C Programming 2.6 Decision Making: Equality and Relational Operators 2 Executable statements Perform actions (calculations, input/output of data) Perform decisions - May want to print

More information

Repetition. Chapter 6

Repetition. Chapter 6 Chapter 6 Repetition Goals This chapter introduces the third major control structure repetition (sequential and selection being the first two). Repetition is discussed within the context of two general

More information

Python allows variables to hold string values, just like any other type (Boolean, int, float). So, the following assignment statements are valid:

Python allows variables to hold string values, just like any other type (Boolean, int, float). So, the following assignment statements are valid: 1 STRINGS Objectives: How text data is internally represented as a string Accessing individual characters by a positive or negative index String slices Operations on strings: concatenation, comparison,

More information

Week 2. Relational Operators. Block or compound statement. if/else. Branching & Looping. Gaddis: Chapters 4 & 5. CS 5301 Spring 2018.

Week 2. Relational Operators. Block or compound statement. if/else. Branching & Looping. Gaddis: Chapters 4 & 5. CS 5301 Spring 2018. Week 2 Branching & Looping Gaddis: Chapters 4 & 5 CS 5301 Spring 2018 Jill Seaman 1 Relational Operators l relational operators (result is bool): == Equal to (do not use =)!= Not equal to > Greater than

More information

Loops. Repeat after me

Loops. Repeat after me Loops Repeat after me 1 Loops A loop is a control structure in which a statement or set of statements execute repeatedly How many times the statements repeat is determined by the value of a control variable,

More information

EVALUATION ONLY. In this lesson, you will use advanced. Functions EXCEL 2013 CASE STUDY: ANALYZING A FUNDRAISING CAMPAIGN LEARNING OBJECTIVES

EVALUATION ONLY. In this lesson, you will use advanced. Functions EXCEL 2013 CASE STUDY: ANALYZING A FUNDRAISING CAMPAIGN LEARNING OBJECTIVES EXCEL 2013 3Applying Advanced Functions In this lesson, you will use advanced functions and what-if analyses to facilitate decision making. Complex worksheets for decision making often require advanced

More information