1
© 2002 John Urrutia. All rights reserved.
C:\My Documents\welcome.bmp
Qbasic
Constructing Qbasic Programs
2
© 2002 John Urrutia. All rights reserved.
C:\My Documents\welcome.bmp
Program Development
Problem definition – statement
Who  – The person, group, organization
What – The record, file, system, data
When  The timeframe
Where The location
Why    The business reason
3
© 2002 John Urrutia. All rights reserved.
C:\My Documents\welcome.bmp
Steps in Program Development
1. Clearly State the Problem
Data
Input – what are the data sources.
Output – what are the data sinks.
Process (algorithm)
Detailed description of how the Input ismanipulated into Output.
4
© 2002 John Urrutia. All rights reserved.
C:\My Documents\welcome.bmp
Data decomposition – the process of:
Identifying the required output.
Reports
Files
Identifying the raw input data needed tofind a solution.
Can be an elementary data element
Can be a grouped data element
Steps in Program Development
5
© 2002 John Urrutia. All rights reserved.
C:\My Documents\welcome.bmp
The Algorithm – is the process
Sequence – linear execution ofinstructions
Selection – Identify a processing path
Binary
Case
Iteration – repetitive execution ofinstructions
Steps in Program Development
6
© 2002 John Urrutia. All rights reserved.
C:\My Documents\welcome.bmp
Steps in Program Development
2. Plan the Logic of the program
Use one or more of these tographically represent the algorithm.
Flowchart
Pseudocode
Hierarchy chart
7
© 2002 John Urrutia. All rights reserved.
C:\My Documents\welcome.bmp
Flowcharts
A graphical representation of theproblem definition
Process
Decision
Termination
Manual
Screen
Steps in Program Development
8
© 2002 John Urrutia. All rights reserved.
C:\My Documents\welcome.bmp
Hierarchy charts (Visual TOC)
A graphical representation of thefunctional decomposition
Steps in Program Development
Room Area
 Program
Room Area
 Program
Room Area
 Program
Room Area
 Program
9
© 2002 John Urrutia. All rights reserved.
C:\My Documents\welcome.bmp
Steps in Program Development
Pseudocode
An English-like representation of theproblem definition
 IF the meat is green THEN
move it to the waste bucket
ELSE
move it to the good bucket.
10
© 2002 John Urrutia. All rights reserved.
C:\My Documents\welcome.bmp
Steps in Program Development
3. Code the program
The syntactical exercise of convertingthe program design into a specificprogramming language.
This should be done first on paper.
11
© 2002 John Urrutia. All rights reserved.
C:\My Documents\welcome.bmp
Steps in Program Development
4. Key the program.
Transfer the coded program into theQBASIC environment and save it as aQBASIC file.
MyProg.bas
12
© 2002 John Urrutia. All rights reserved.
C:\My Documents\welcome.bmp
Steps in Program Development
5. Test and Debug the program.
V&V –Verification & Validation
Verification –Are we doing the right job?
Validation –Are we doing the job right?
13
© 2002 John Urrutia. All rights reserved.
C:\My Documents\welcome.bmp
Steps in Program Development
Specification errors –
Problem definition omissions,inaccuracies, lack of clarity
Syntax errors –
Coding or Keying
Logic errors
Do what I think not what I say…
14
© 2002 John Urrutia. All rights reserved.
C:\My Documents\welcome.bmp
Steps in Program Development
6. Complete the Documentation
Develop a program package containing:
Program specification, hierarchy chart,flowchart, and pseudocode.
Test plan and results
Final version of tested program
15
© 2002 John Urrutia. All rights reserved.
C:\My Documents\welcome.bmp
B. A. S. I. C.
Beginners
All-purpose
Symbolic
Instruction
Code
QBasic – QuickBASIC
Developed at Dartmouth in 1960’s
16
© 2002 John Urrutia. All rights reserved.
C:\My Documents\welcome.bmp
Qbasic Character Set
Letters:a-z and A-Z
Digits:0-9
Blank:the space character (   )
Special characters:+ - * / \ = < > . , ’ ” ( ) : ; ^ _ $ # ? ! % &
17
© 2002 John Urrutia. All rights reserved.
C:\My Documents\welcome.bmp
Qbasic Keywords
keyword has a predefined meaningwithin Qbasic.
Examples:LET   END   REM   PRINT
18
© 2002 John Urrutia. All rights reserved.
C:\My Documents\welcome.bmp
The QBASIC Environment
QBASIC is an interpreter
Each line of code is translated intomachine language just prior to itsexecution… every time.
Creates an interactive environmentthat’s easy to work with.
19
© 2002 John Urrutia. All rights reserved.
C:\My Documents\welcome.bmp
QBASIC …
20
© 2002 John Urrutia. All rights reserved.
C:\My Documents\welcome.bmp
Demonstration
21
© 2002 John Urrutia. All rights reserved.
C:\My Documents\welcome.bmp
The CLS statement
CLear Screen
Erases all characters from the terminal
Places cursor at position 1,1(top left corner)
22
© 2002 John Urrutia. All rights reserved.
C:\My Documents\welcome.bmp
The PRINT statement
Writes information to the terminal.
PRINT output-list
PRINT X$
PRINT 5 + 7
PRINT “Hello World”
PRINT  (prints a blank line)
23
© 2002 John Urrutia. All rights reserved.
C:\My Documents\welcome.bmp
The PRINT statement
Horizontal spacing
Each PRINT statement will occupy oneline on the users screen
Vertical spacing
– places data adjacent to each other
– places data at multiples of 14     columns on the line