CSIT 208, Section 32301 Instructor: P eter C hen Introduction to Programming with QBasic to Visual Basic Lecture 8.

Slides:



Advertisements
Similar presentations
Introduction to File I/O How to read & write data to a disk file...
Advertisements

Standard Algorithms Find the highest number. ! Your name and today’s date ! Find the maximum Dim numbers(20) As Integer.
CS107 Introduction to Computer Science Lecture 2.
VB PROJECT “PROJECT SAMPLES”. For Next Loops Design a VB program that displays in a picture box the first N multiples of an input integer Input 3 exam.
Files Organisation sequential files. Readings u Schneider Chapter 8 u Shelly Cashman to 9.14; to 9.11 u Meyer to 2-37; 1995.
@ Zhigang Zhu, CSC212 Data Structure - Section FG Lecture 19 Searching Instructor: Zhigang Zhu Department of Computer Science City College.
Chapter 8 - Visual Basic Schneider1 Chapter 8 Sequential Files.
Introduction to Computers and Programming Lecture 10: For Loops Professor: Evan Korth New York University.
Binary Search Visualization i j.
©Brooks/Cole, 2001 Chapter 13 Binary Files. ©Brooks/Cole, 2001 Figure 13-1.
Chapter 7 - Visual Basic Schneider1 Chapter 7 Arrays.
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.
Designing Algorithms February 2nd. Administrativia Lab assignments will be due every Monday Lab access –Searles 128: daily until 4pm unless class in progress.
CS107 Introduction to Computer Science Lecture 2.
Designing Algorithms Csci 107 Lecture 3. Designing algorithms Last time –Pseudocode –Algorithm: computing the sum 1+2+…+n –Gauss formula for 1+2+…+n Today.
Introduction to Computing Dr. Nadeem A Khan. Lecture 24.
Chapter 8 - Visual Basic Schneider1 Chapter 8 Sequential Files.
Designing Algorithms Csci 107 Lecture 3. Administrativia Lab access –Searles 128: daily until 4pm unless class in progress –Searles 117: 6-10pm, Sat-Sun.
Chapter 7 - Visual Basic Schneider1 Chapter 7 Arrays.
Introduction to Computing Dr. Nadeem A Khan. Lecture 28.
Two-Dimensional Arrays School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 11, Friday 4/04/2003)
1 Lab Session-6 CSIT-121 Spring 2005 Structured Choice The do~While Loop Lab Exercises.
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 7 - Visual Basic Schneider1 Chapter 7 Arrays.
Searching and Sorting Arrays
1 Lab Session-7 CSIT-121 Fall Introducing Structured Choice 4 The do~While Loop 4 Lab Exercises.
Chapter 7 - Visual Basic Schneider
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.
ISAT 252 Introduction to Arrays. Should have read 2 Chapter 8 –pp , and pp
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Microsoft Visual Basic 2008 CHAPTER NINE Using Arrays and File Handling.
Microsoft Visual Basic 2005 CHAPTER 9 Using Arrays and File Handling.
Copyright © 2003 Pearson Education, Inc. Slide 5-1 The Web Wizard’s Guide to PHP by David Lash.
Using Arrays and File Handling
Array Processing Simple Program Design Third Edition A Step-by-Step Approach 7.
Chapter 10 Applications of Arrays and Strings. Chapter Objectives Learn how to implement the sequential search algorithm Explore how to sort an array.
Efficiency of Algorithms Csci 107 Lecture 7. Last time –Data cleanup algorithms and analysis –  (1),  (n),  (n 2 ) Today –Binary search and analysis.
Starting Out with C++, 3 rd Edition 1 Searching an Arrays.
MS 101: Algorithms Instructor Neelima Gupta
Data files and databases. Need a control to browse to a file Standard controls for drive folder and list not much use The CommonDialogs control offers.
© 1999, by Que Education and Training, Chapter 8, pages of Introduction to Computer Programming with Visual Basic 6: A Problem-Solving Approach.
Value and Reference Parameters. CSCE 1062 Outline  Summary of value parameters  Summary of reference parameters  Argument/Parameter list correspondence.
Introduction to C++ Programming Language Assistant Professor Jeon, Seokhee Assistant Professor Department of Computer Engineering, Kyung Hee University,
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 10: Applications of Arrays (Searching and Sorting) and the vector Type.
Count and add list of numbers From user input and from file.
Computer Programming TCP1224 Chapter 11 Arrays. Objectives Using Arrays Declare and initialize a one-dimensional array Manipulate a one-dimensional array.
Course roster management in scheme Data to be managed – A class roster is list of student entries of the form (ID, name, grade) – Example (“001”, “John.
Sequential files School of Business Eastern Illinois University © Abdou Illia, Spring 2003 (Week 12, Monday 4/07/2003)
Using Text Files in Excel File I/O Methods. Working With Text Files A file can be accessed in any of three ways: –Sequential access: By far the most common.
Copyright © 2001 by Wiley. All rights reserved. Chapter 6: Using Arrays Control Arrays List Arrays Finding Items in Arrays Multiple Forms 2-Dimensional.
6-1 Chapter 6 Working with Arrays in VB.NET. 6-2 Learning Objectives Understand the use of list and table arrays in VB.NET projects and the difference.
CSIT 208, Section Instructor: P eter C hen Introduction to Programming with QBasic to Visual Basic Lecture 9.
File Handling in QBASIC
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
CHAPTER EIGHT ARRAYS © Prepared By: Razif Razali1.
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.
Introduction to Arrays. Objectives Distinguish between a simple variable and a subscripted variable. Input, output, and manipulate values stored in a.
Chapter 8 Slides from GaddisText Arrays of more than 1 dimension.
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.
Array Applications. Objectives Design an algorithm to load values into a table. Design an algorithm that searches a table using a sequential search. Design.
Introduction to Programming Lecture 12. Today’s Lecture Includes Strings ( character arrays ) Strings ( character arrays ) Algorithms using arrays Algorithms.
Chapter 7 Arrays.
Starting Out with Programming Logic & Design
CSC212 Data Structure - Section RS
Databases Lesson 2.
In Class Programming BIS1523 – Lecture 11.
Video list editor BIS1523 – Lecture 24.
Topics Introduction to File Input and Output
CSC212 Data Structure - Section KL
Chapter 8 - Visual Basic Schneider
Presentation transcript:

CSIT 208, Section Instructor: P eter C hen Introduction to Programming with QBasic to Visual Basic Lecture 8

CSIT 208, Section CLS INPUT “Enter the name of a corporation: “, corp$ LET foundFlag = 0 LET first = 1 LET last = 100 DO WHILE (first <= last) AND (foundFlag = 0) LET middle = INT(first + last)/2) SELECT case firm&(middle) CASE corp$ LET foundFlag = 1 CASE IS > corp$ LET first = middle – 1 CASE IS < corp$ LET first = middle + 1 END SELECT LOOP IF foundFlag = 1 THEN PRINT corp$; “ found” ELSE PRINT corp$; “ not found” END IF END Binary Search * Page 267 Assume the array firm$() contains the Alphabetized names Of 100 corporations

CSIT 208, Section Two-Dimensional Arrays CLS DIM rm ( 1 TO 4, 1 TO 4) CALL ReadMileages(rm()) CALL ShowCitites CALL ShowMileage(rm(), row, col) DATA 0, 2054, 802, 738 DATA 2054, 0, 2786, 2706 DATA 802, 2786, 0,100 DATA 738, 2706, 100, 0 END SUB InputCities (row, col) INPUT “Origin”; row INPUT “Destination”; col END SUB Continue … * Page 276

CSIT 208, Section SUB ReadMileages (rm()) FOR row = 1 TO 4 FOR col = 1 TO 4 READ rm (row, col) NEXT col NEXT row END SUB SUB ShowCities PRINT “1. Chicago” PRINT “2. Los Angeles” PRINT “3. New York” PRINT “4. Philadelphia” END SUB SUB ShowMileage (rm(), row, col) PRINT “ The road mileage is”; rm(row, col) END SUB

CSIT 208, Section Exercise Please add one more destination, (5. San Francisco) Distance: San Francisco  Chicago, 1500 San Francisco  Los Angeles, 200 San Francisco  New York, 4000 San Francisco  Philadelphia, 3500

CSIT 208, Section Chapter 8 - WRITE Statement CLS WRITE “Eric” WRITE 1946 WRITE “Eric”, 1946 LET a$ = “John” LET b$ = “Smith” WRITE 14 * 139, “J.P “ + a$, b$, “Amy” END * Page 303

CSIT 208, Section Sequential File OPEN “YOB.DAT FOR OUTPUT AS #1 READ name$, year DO WHILE name$ <> “EOD” WRITE #1, name$, year READ name$, year LOOP CLOSE #1 DATA Barbara, 1942 DATA Ringo, 1940 DATA Sylvester, 1946 DATA EOD, 0 END * Page 304

CSIT 208, Section Exercise Write a program to create the file “student.dat”. Use EOD as a sentinel to indicate that all the data have been read. Please input three student’s first name, last name, and ID Number.

CSIT 208, Section Adding Items to a Sequential File CLS OPEN “YOB.DAT” FOR APPEND AS #1 INPUT “Name, Year of Birth”; name$, year WRITE #1, name$, year CLOSE #1 END

CSIT 208, Section Exercise Write a program to append John Smith, ID number: 7773 into the student.dat file.