Chapter six exercises. 6.1 1. 17 2. 0 1000 1 1100 2.

Slides:



Advertisements
Similar presentations
Chapter 6 - VB 2005 by Schneider1 Do Loop Syntax Do While condition statement(s) Loop Condition is tested, If it is True, the loop is run. If it is False,
Advertisements

MATLAB Examples. CS 1112 MATLAB Examples Find the number of positive numbers in a vector x = input( 'Enter a vector: ' ); count = 0; for ii = 1:length(x),
Fundamentals of Programming in Visual Basic
General Computer Science for Engineers CISC 106 Lecture 19 Dr. John Cavazos Computer and Information Sciences 04/06/2009.
Chapter seven review Monther Aldwairi. What is the output of: Private Sub cmdButton_Click() Dim i As Integer, a(1 To 4) As integer Open "DATA.TXT" For.
Types of LOOP Structures Do While ……. Loop Do Until …… Loop For …… Next loop.
Chapter 4 - Visual Basic Schneider
Lecture 7 Sept 17 Goals: Complete Chapter 4 Chapters 5 and 6.
Nested Loops. For i = 1 To 5 For j = 1 To 6 picOutput.Print "*"; Next j picOutput.Print Next i.
Unit 171 Algorithms and Problem Solving  Introduction  Algorithm Design  Algorithm Properties  Algorithm Control Flow  Examples  Comparing Algorithms.
Chapter 7 - Visual Basic Schneider1 Chapter 7 Arrays.
Two-Dimensional Arrays School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 11, Friday 4/04/2003)
Chapter seven review. What is the output of: Private Sub cmdButton_Click() Dim i As Integer, a(1 To 4) As integer Open "DATA.TXT" For Input As #1 For.
User-Defined Data Types School of Business Eastern Illinois University © Abdou Illia, Fall 2002 (Week 13, Monday 11/18/2002)
Chapter 6 - Visual Basic Schneider1 Chapter 6 Repetition.
Chapter 41 Sub Procedures, Part II (Continue). Chapter 42 Local Variable A variable declared inside a Sub procedure with a Dim statement Space reserved.
Chapter 5 - Visual Basic Schneider1 Chapter 5 Decisions.
1 Chapter 7 Arrays. 2 Outline and Objective In this chapter we will Learn about arrays One-dimensional arrays Two-dimensional arrays Learn about searching.
Chapter 4 - Visual Basic Schneider1 Chapter 4 General Procedures.
Chapter 6 - Visual Basic Schneider
Chapter 6 - Visual Basic Schneider1 Chapter 6 Repetition.
Chapter 7 - Visual Basic Schneider1 Chapter 7 Arrays.
Arrays. What is the output of: Private Sub cmdButton_Click() Dim i As Integer, a(1 To 4) As integer Open "DATA.TXT" For Input As #1 For i = 1 To 4 Input.
Chapter 7 - Visual Basic Schneider
1 Chapter 6 Repetition. 2 Outline & Objectives Loop Structure Loop Structure Elements of a Loop Structure Elements of a Loop Structure Processing Lists.
1 Chapter 7 Arrays. 2 Outline and Objective In this chapter we will –Learn about arrays One-dimensional arrays Two-dimensional arrays –Learn about searching.
COMPE 111 Introduction to Computer Engineering Programming in Python Atılım University
1 Chapter 6 – Repetition 6.1 Do Loops 6.2 For...Next Loops 6.3 List Boxes and Loops.
Array Processing: Exercises School of Business Eastern Illinois University © Abdou Illia, Spring 2002 (Week 10, Friday 3/28/2003)
Review for Exam 2 School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 10, Friday 3/21/2003) - IF Blocks - Do Loops - Select.
Microsoft Access Using Visual Basic Routines. Visual Basic Datatypes Boolean Byte Currency Date Double Integer Long Object Single String Variant Hyperlink.
Chapter four selected exercises with solutions. 4.2.
Chapter 6 - VB 2005 by Schneider1 Chapter 6 – Repetition 6.1 Do While and Do Until Loops 6.2 Processing Lists of Data with Do Loops 6.3 For...Next Loops.
ENGR 112 Decision Structures.
Sub procedures School of Business Eastern Illinois University © Abdou Illia, Spring 2002 (Week 6, Friday 2/21/03)
VB Core II Conditional statements Exception handling Loops Arrays Debugging.
Programming Test #1 Solutions. Multiple Choice 1. B) the grammar of the coding language 2. C) String 3. A) Single 4. C) 2Burgers4Me 5. B) Design Time.
Do Loop with Interest Please see speaker notes for additional information!
Chapter 6 - Visual Basic Schneider 1 Chapter 6 Repetition.
CHAPTER SIX LOOPS © Prepared By: Razif Razali 1. FORMAT OR REFRESH!! WHAT HAVE WE LEARN? Differentiate between the types of selection structure? Which.
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.
Chapter 8 - Visual Basic Schneider
Count and add list of numbers From user input and from file.
A loop is a repetition control structure. body - statements to be repeated control statement - decides whether another repetition needs to be made leading.
Repetition Chapter 6 - Visual Basic Schneider 1  Loop Structure  Elements of a Loop Structure  Processing Lists of Data with Do Loops Chapter 6 -
Repetition Structures
Review for Final (Part 2) School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 15, Friday 5/2/2003)
Chapter 3 - Visual Basic Schneider Numeric Variables Used to store numbers Value is assigned by a statement of the form: numVar = expression The variable.
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.
Sub Procedures; Passing Values Back From Sub Procedures Passing by reference Passing by value.
Chapter81 For....Next Loops n For i = m To n statement (s) Next i n For statement designates a numeric variable, called control variable. n It is initialized.
Chapter 4 - Visual Basic Schneider1 Chapter 4 General Procedures.
Fourth Quarter.  Involves loops or cycles ◦ Loops: means that a process may be repeated as long as certain condition remains true or remains false. ◦
Two-Dimensional Arrays. Two-dimensional arrays variables store the contents of tables or matrices. Example: Dim arrTable(1 to 5, 1 to 5) As Integer first.
CSCI 3327 Visual Basic Chapter 4: Control Statements in Visual Basic (Part 2B) UTPA – Fall 2011 Part of the slides is from Dr. John Abraham’s previous.
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.
1 VB-04-Control Structures 16 March 2016 Visual Basic Control Structures - Selection.
Chapter 6 - Visual Basic Schneider1 Chapter 6 Repetition.
Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Third Edition by Tony Gaddis.
Introduction to Programming Lecture 12. Today’s Lecture Includes Strings ( character arrays ) Strings ( character arrays ) Algorithms using arrays Algorithms.
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.
Select Case Blocks School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 8, Monday 3/03/2003)
User-Defined Data Types
Chapter 4 - Visual Basic Schneider
Lbound and Ubound Functions
Function Procedures.
The structure of programming
For...Next Statements.
Introduction to Algorithms - 2
Introduction to Algorithms - 2
Presentation transcript:

Chapter six exercises

6.1

3. You are a super programmer!

7. The value of q keeps growing until the program crashes when the value exceeds the upper limit for a variable of the type Single. 8. Program never stops. The line n = 1 should appear before the Do loop.

11. While num >= While nom <> "Bob" 13. Until response <> "Y" 14. Until total <> Until nom = "" 16. While balance < Until (a = 3) 18. While (ans <> "") And (n <> 0) 19. While n = Until (ans <> "Y") Or (n >= 7)

Private Sub cmdDisplayConvTable_Click() Dim celsius As Single picTempTable.Cls picTempTable.Print "Celsius"; Tab(10); "Fahrenheit" celsius = -40 Do While celsius <= 40 picTempTable.Print celsius; Tab(10); (9 / 5) * celsius + 32 celsius = celsius + 5 Loop End Sub

Private Sub cmdFindPrimeFactors_Click() Dim n As Integer, f As Integer 'Prime factorization picFactors.Cls n = Val(InputBox("Enter an integer greater than 1:")) picFactors.Print "The prime factors of"; n; "are:" f = 2 Do While n > 1 If (n Mod f) <> 0 Then 'Or If Int(n/f) <> n/f Then f = f + 1 Else picFactors.Print f; n = n / f End If Loop End Sub

6.2

Roxie 3. pie Velma cake melon 4. Chicago 8.8 New York 20.1

6.3

1. Pass # 1 Pass # 2 Pass # 3 Pass # Who do we appreciate?

8. Average = 90

17. Private Sub cmdDisplay_Click() Dim num As Integer For num = 1 To 10 Step 2 picOutput.Print num Next num End Sub 18. Private Sub cmdDisplay_Click() Dim num As Integer For num = 1 To 4 picOutput.Print "hello" Next num End Sub

19. Private Sub cmdDisplay_Click() Dim i As Integer 'Display a row of 10 stars picOutput.Cls For i = 1 To 10 picOutput.Print "*"; Next i End Sub 20. Private Sub cmdDisplay_Click() Dim i As Integer, stars As Integer 'Display a row of stars picOutput.Cls stars = Val(InputBox("Row length (1-20) : ")) For i = 1 To stars picOutput.Print "*"; Next i End Sub

21. Private Sub cmdDisplay_Click() Dim i As Integer, j As Integer 'Display 10 x 10 array of stars picOutput.Cls For i = 1 To 10 For j = 1 To 10 picOutput.Print "*"; Next j picOutput.Print Next i End Sub

35. Private Sub cmdDraw_Click() Dim stars As Integer, i As Integer picOutput.Cls picOutput.Font.Name = "Courier New" stars = Val(InputBox("Number of stars?")) For i = 1 To stars picOutput.Print "*"; Next i picOutput.Print For i = 1 To stars - 2 picOutput.Print "*"; For j = 1 To stars - 2 picOutput.Print " "; Next j picOutput.Print "*" Next i For i = 1 To stars picOutput.Print "*"; Next i End Sub

36. Private Sub cmdDraw_Click() Dim stars As Integer, topSize As Integer 'Draw a triangle picOutput.Cls picOutput.Font.Name = "Courier New" topSize = Val(InputBox("Enter an odd number:")) For stars = topSize To 1 Step -2 For i = 1 To stars picOutput.Print "*"; Next i picOutput.Print Next stars End Sub