Introduction To Computer
Introduction To Computer
Sciences
FSC 103
* Term assignment.
LECTURE 1
LECTURE 1
Documen Problem
tation Analysis
Development or Design /
Implementation
Model
• Problem Definition:
– Program to find the sum of the first 10 natural
numbers
– Output = Pension
1. i 1
2. SUM 0
3. SUM SUM + i
4. i i + 1
5. If i > 10 GOTO Step 7
6. Else GOTO step 3
7. STOP
START / STOP
PROCESS
DECISION
INPUT / OUTPUT
PREDEFINED PROCESS
CONNECTOR
LOGIC FLOW
FSC 103 NOT FOR SALE PLEASE
Class Programming Example
Flowchart for Summing first 10 natural numbers
START
i = 1, SUM = 0
Is i > YES
STOP
10
NO
SUM = SUM + i
i=i+1
CHECK CUSTOMER
STATUS
Order
NEW
CUSTOME
YES >
R? N5000
?
NO NO YES
* To be demonstrated in class
Example
amount = 10000
fName = “ADE”
address = “BlockFSC2,103House 14, Ikeja”
NOT FOR SALE PLEASE
DATA TYPES IN VB
• Data type is the attribute of a variable or field
which determines the kind of data it can hold.
Example: 2 * 8 + 10
– Relational Operators
These operators result in either True or False.
These can also be classified as Boolean operation
• Logical Operators
– These include AND, NOT, XOR, OR, EQV
^ Exponential 2
NOT Negation 3
* and / Multiplication & Division 4
\ Integer Division 5
Mod Modulus 6
+ and - Addition or Subtraction 7
• Example
1. If logical expression is true then execute this
Else execute something else
End If
Do Until Do While
Example Example
a = 100, b = 10 a = 100, b = 10
Do Until ( a < b) Do While ( a > b)
b= a–b b= a–b
loop loop
These two loop statement accomplish the same thing and are examples
of PRE-TEST loop statements.
That is the test condition is tested first before executing the body of the loop
FSC 103 NOT FOR SALE PLEASE
DO..LOOP CONT’D
Do Until Do While
Example Example
a = 100, b = 10 a = 100, b = 10
Do Do
b= a–b b= a–b
Loop Until ( a < b) Loop While ( a > b)
Tool Bar
• Menu Bar
– Provides access to most of the commands that control the programming
environment (IDE), such as File, View, Tools etc.
• Tool Bar
– Collection of buttons that serve as shortcuts for executing commands and
controlling the VB IDE. It includes icons such as OPEN File, SAVE, New Project
etc
• Tool Box
– This gives easy access to common VB controls or tools such as textbox,
command button, list box, etc.
• Properties Explorer
– The properties window allows you to view and edit properties associated with
any particular form or control element.
• Project Window
– The project window shows all the files and folders included within the project.
• Code Editor
– The code editor window is used to manually write codes / program instructions
for a control. There is a separate code editor window associated with each form
FSC 103 NOT FOR SALE PLEASE
COMMON WINDOWS FORM CONTROLS VB
• Problem Analysis:
– Input = radius of the circle
– Output = area & circumference
– Procedure:
• Area = Pi * radius * radius
• Circumference = 2 * Pi * radius
– Variables:
Start
• Dim rad as Integer
• Dim area as Double
Enter • Dim cirm as Double
RADIUS
– Sketch what the
application would look
Output
Area = Pi * RADIUS2
Area & like
Cirmf = 2* Pi * RADIUS
Cirmf
Stop
• Documentation
Dim result = 0
TextBox3.Text = result
End Sub