0% found this document useful (0 votes)
2 views

Introduction to Computer Systems

The document outlines the course details for Introduction to Computer Sciences (FSC 103), including objectives, programming concepts, and the Software Development Life Cycle (SDLC). It introduces key programming concepts, such as algorithms, flowcharts, and the use of Visual Basic as a programming language. The course aims to equip students with foundational knowledge in programming and software development.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Introduction to Computer Systems

The document outlines the course details for Introduction to Computer Sciences (FSC 103), including objectives, programming concepts, and the Software Development Life Cycle (SDLC). It introduces key programming concepts, such as algorithms, flowcharts, and the use of Visual Basic as a programming language. The course aims to equip students with foundational knowledge in programming and software development.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 69

Introduction to Computer

Sciences
FSC 103

2015/2016 Academic Session

FSC 103 NOT FOR SALE PLEASE


Course Details
• Venue: DLI, Auditorium A, B & C
• Time: Tuesdays 8am – 10am
• Lecturer: Mrs. Ojiako, Mr. Ajayi & Mr.
Edagbami
• Texts: Computer Fundamentals &
Visual Basic Language
(Highly recommended),
Other relevant texts
FSC 103 NOT FOR SALE PLEASE
Course Objectives
At the end of this course, students
should:

• Understand the Software Development


Life Cycle (SDLC).

• Be introduced to writing programs in


Visual Basic

FSC 103 NOT FOR SALE PLEASE


Outline
• Introduction to Programming (2
Parts).

• Programming with Visual Basic (2


Parts).

* Term assignment.

FSC 103 NOT FOR SALE PLEASE


Introduction

LECTURE 1

FSC 103 NOT FOR SALE PLEASE


What is a Computer?
• It can be defined as a data processing
machine that is capable of accepting input
from users in form of data, processing or
storing these data and giving output
based on user supplied logic.

• A computer is a general purpose device


that can be programmed to carry out a
set of arithmetic or logical operations
automatically

FSC 103 NOT FOR SALE PLEASE


Types of Computers

FSC 103 NOT FOR SALE PLEASE


Source: informationq.co m
Stored Program Concept
• A concept of storing alterable
instructions that will direct the
machine to automatically perform
the necessary processing steps to
carry out a task.

• This is the major feature that


distinguishes a computer from a
basic calculator or other data
processing machines
FSC 103 NOT FOR SALE PLEASE
Machine of Machines
• Computers on their own are dumb machines
that simply do nothing. It is the program
supplied that actually makes them useful.

• A computer for example becomes an


arithmetic calculator or a music player once a
calculator or media player program is loaded
into it.

FSC 103 NOT FOR SALE PLEASE


Introduction to
Programming
LECTURE 1

FSC 103 NOT FOR SALE PLEASE


What is a Computer
Program
• A computer program is a sequence of
simple logical instructions into which
a given problem is reduced and
which is in a form a computer can
understand.

• A given problem can be broken


down/reduced into…
– Sequence of simple logical instructions
– A form the computer
FSC 103 NOT FOR SALEcan
PLEASE understand
• A program is simply a list of logical
instructions that tell the computer what to
do.
– Simple addition program
• Accept first number = x
• Accept second number = y
• Add x and y = z
• Output z as answer

• The program should incorporate the


logical procedure to solving a given
problem, hence a computer does not
produce logic, it simply follows that, which
is supplied in the programmers codes.
FSC 103 NOT FOR SALE PLEASE
• Computer Programming is the act of writing
code which can be executed by a computing
system to perform a meaningful task or give
a desired result.

• Programs are written to solve specific


problems of varying level of complexity
requiring different level of resources and
planning.

A sample program might be to add/subtract


two numbers while another to manage the
customers’ accounts of a large enterprise bank
FSC 103 NOT FOR SALE PLEASE
• All problems to be solved by a
computer must be broken down into
four basic operations:
– Calculating or computing
– Comparing and testing
– Shifting operation
– Jumping operations

As long as a problem can be reduced to


these basic operations it can be solved.

FSC 103 NOT FOR SALE PLEASE


The Software Development Life
Cycle
Problem
Definition

Documen Problem
tation Analysis

Development or Design /
Implementation
Model

FSC 103 NOT FOR SALE PLEASE


*Software Development Life Cycle (SDLC)
Problem Definition
• A complete, precise and unambiguous
statement of the problem to be solved.

• It is a clear definition of what the


program does or is meant to do.

Problem definition example:


“Program to Multiply two integer numbers”
“Program to calculate XYZ Limited’s current
employee pension”
FSC 103 NOT FOR SALE PLEASE
Class Programming Example
Write a program to sum first 10 natural
numbers.

• Problem Definition:
– Program to find the sum of the first 10
natural numbers

FSC 103 NOT FOR SALE PLEASE Start from 0 or from 1


Problem Analysis
• A thorough examination of the problem
defined in the problem definition stage.

• It involves breaking down the problem


into its constituent parts and determine
what is/are needed to solve the it.

• Here the Input(s), Output(s) and


Procedure(s) are identified.
FSC 103 NOT FOR SALE PLEASE
Problem Analysis Example
• Program to calculate XYZ Limited’s current
employee pension

– Input = EmployeeID, [Full Name], Department,


Designation, Employment Date, Salary,
Pension percentage

– Output = Pension

– Procedure = Get active service year by subtracting


current date from employment date,
then multiple by the pension
percentage to get pension value
FSC 103 NOT FOR SALE PLEASE
* More examples available in the course text
Class Programming Example
Problem Analysis:

• The first 10 natural numbers are:


1,2,3,4,5,6,7,8,9,10
• Input = first 10 natural numbers
• Output = the summation
• Procedure=
Start from the first natural number (1).
Add the next number to it
Store summation
Continue till
FSC the
103 NOTtenth natural number
FOR SALE PLEASE
Model / Design
• A model is an abstraction of the real
problem and it defines the
relationship between objects of the
problem space.

– Mathematical models illustrated on page


74 of course text.
– Logical model: flowchart, business
process chart
FSC 103 NOT FOR SALE PLEASE
Algorithm
• A finite process or set of rules which
spells out a step-by-step sequence of
operations to be followed to solve a
specific
Finite problem. It must end
Definite steps Each step must be clear,
precise and unambiguous
Input It should have at least an
input
Output It should have at least an
output
Effective The steps can be done
exactly in a finite and
FSC 103 NOT FORreasonable
SALE PLEASE length of time
Examples of Algorithm: Simple
Addition
Given 1234 + 5678
1. Arrange the two numbers in
standard form.
2. Start with right most c
column (current column). 1 2 3 4
3. Add the digits in the current
5 6 7 8
column.
2
4. If sum < 10, record sum
under current column
5. If sum > 10, subtract 10
from the sum and record
remainder, add 1 to the
column left of current
column.
6. Current column =
immediate left column
7. If current column is empty
then stop else goto FSC 103 NOT FOR SALE PLEASE
step 3
Algorithm Notations
• Assignment notation:
A B, meaning assign value of B
to A
• Arithmetic notations: +, -, *, /
• Logical notations: =, <>, ≠, <, >

FSC 103 NOT FOR SALE PLEASE


Simple Addition Algorithm
V1 1 2 3 4
1. Set V1, V2 and SUM
V2 5 6 7 8
0 SUM 6 9 1 2
2. Set V1 1234
3. Set V2 5678
4. SUM V1 + V2
5. Output SUM as
answer

FSC 103 NOT FOR SALE PLEASE


Class Programming Example
• Sum of first 10 Plan / Procedure
numbers, ie • Let n = number of
1 + 2 + 3 + 4 +5 + 6 natural numbers ie 10.
+ 7 + 8 + 9 + 10 • Let SUM = summation
• Let i = current number
Written mathematically • Initialize all variables*
as n = 10
SUM = 0
i=1
S=
• Thus the algorithm is
FSC 103 NOT FOR SALE PLEASE
*Why initialize? Page 83 & 84 of Course Text for de
Algorithm to sum first 10 natural numbers

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
FSC 103 NOT FOR SALE PLEASE
FLOW CHART
• A flowchart is a diagram that
presents logical structures pictorially.

• It serves to help a person easily


understand a program written by
someone else.

• To achieve this, present / standard


symbols are used to denote different
operations. These most used symbols
FSC 103 NOT FOR SALE PLEASE
Flowchart Symbols
SYMBOL MEANING

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

FSC 103 NOT FOR SALE PLEASE


Flowchart Example 2

• The order of a new customer is


accepted provided it is not more than
N5,000 otherwise it is referred to a
supervisor. An order from a regular
(old) customer is always accepted.

– Define the problem


– Analyze the problem
– Draw a flowchart
FSC 103 NOT FOR SALE PLEASE
Flow Chart
START

CHECK
CUSTOMER
STATUS
Order
NEW
CUSTOM
YES >
ER? N500
0?
NO NO YES

ACCEPT REFER TO
ORDER SUPERVISOR

FSC 103 NOT FOR SALE PLEASE


DEVELOPMENT & IMPLEMENTATION
(PROGRAMMING)

FSC 103 NOT FOR SALE PLEASE


DOCUMENTATION
• Programs are meant to be documented, much
like how an equipment manufacturer adds a
USER MANUAL.

• This ensures that others can read the


documentation and use the appliance / program.

• Documentation should start from the Problem


Definition stage and run all the way to the
programming stage and even beyond (such as
pictures of the program in use and possibly
maintenance / troubleshooting
FSC 103 NOT FOR SALE PLEASE
steps).
PROGRAMMING IN VISUAL
BASIC
LECTURE 2

FSC 103 NOT FOR SALE PLEASE


VISUAL BASIC
• BASIC means Beginners All-Purpose Symbolic
Instruction Code.

• It is arguably the most used programming language in


the history of computing.

• It is a very simple but powerful programming


language that combines the mathematical capabilities
of FORTRAN and the business orientation of COBOL.

• VISUAL refers to the method used to create Graphic


User Interfaces.

FSC 103 NOT FOR SALE PLEASE


TYPES OF PROGRAMMING
LANGUAGES
• PROCEDURAL PROGRAMMING LANGUAGE:
This is essentially a list of instructions
telling the computer what to do step-by-
step, from the first line to the last line of
code. These type of language are also
called IMPERATIVE or TOP-DOWN
language. Examples are FORTRAN, COBOL
and C.

FSC 103 NOT FOR SALE PLEASE


Object Oriented Programming
Languages
• Unlike procedural languages, OOP languages are all about objects.
• An object is a self-contained component of a program that knows how to
perform certain actions and how to interact with other elements of the
program.

• Objects are the basic units of object-oriented programming.

• A simple example of an object is a car.


– Make, Model, Colour would be considered as the properties of the car.
– Abilities of a car include Accelerate, Turn, Stop…. these would be considered as
methods of the car.

• A method in object-oriented programming is like a procedure in procedural


programming. The key difference here is that the method is part of an object.
In object-oriented programming, you organize your code by creating objects,
and then you can give those objects properties and methods.

• A key aspect of object-oriented programming is the use of classes. A class is a


template or blueprint of an object. You can think of a class as a concept, and
the object as the embodiment of that concept.
FSC 103 NOT FOR SALE PLEASE
• Examples of object-oriented languages include Visual Basic, C#, Java, Python.
• Visual Basic (VB) is an event-driven OOPL, and
consists of two major components – the
Controls & Commands.

• Controls are graphical items (such as Buttons


& Text Box) that could be placed on the FORM.

• Commands are instructions written by the


programmer instructing VB to carry out a
specified action.

• Event driven means an action has to be


triggered either by the user or a pre-set
system timer. FSC 103 NOT FOR SALE PLEASE
• Event-driven programs have
items/controls on a form, that carry
out associated procedures once a
user interacts with them. Example
includes clicking a button

FSC 103 NOT FOR SALE PLEASE


VB Programming
Environment
• To Launch VB 6: • To Launch VB:NET
– From Windows Desktop
– Click Start
– Click All Programs
– Click Microsoft Visual
Studio 6
– Click on Microsoft
Visual Basic 6.0

* To be demonstrated in
class

FSC 103 NOT FOR SALE PLEASE


Features of VB
• KEYWORD: a pre-defined word that is
already defined and reserved for a
specific purpose. In VB these include:
DIM, REM, LOOP, IF, ELSE, END, FOR, SUB
etc

• CONSTANT: a numeric or string value that


does not change in a program. They
include Integer, Long, Single, Double,
String
FSC 103 NOT FOR SALE PLEASE
* Assignment: Learn all the keywords in VB
Features of VB
• VARIABLES: A location or area within
a computer memory where data
is/are stored.
– Variable name is the name given to a
storage location in a program.
– Variables are assigned values
– The assigned value can change but the
variable name and storage location
cannot change until the program
terminates or the variable is released.

FSC 103 NOT FOR SALE PLEASE


A Variable Name…
• Must begin with a letter
• May contain letters, digits and underscore all
others characters are not allowed (not even
space). Similar to an email address.
• Cannot exceed 255 character in length
• Cannot be a VB keyword
• Can be in any case ie Capital or Small letters.

Example
amount = 10000
fName = “ADE”
address = “Block 2, House 14, Ikeja”
FSC 103 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.

• Common Data types in VB include:


– Integer - String
– long - Boolean
– Array
– User-defined (see page 114 of course
material) FSC 103 NOT FOR SALE PLEASE
DATA DECLARATION IN VB
• The keyword DIM is used to declare
variables in VB.
• It tells VB to reserve a space in
memory for the variable
• Also tells VB what variable type to
expect when the program is executed.
Example
1. Dim name as string
2. Dim phone as long
3. Dim age asFSCinteger
103 NOT FOR SALE PLEASE
OPERATORS IN VB
• There are 3 types of operators in VB
– Arithmetic operators such as addition (+),
subtraction (-), division (/), multiplication (*),
bracket, mod

Example: 2 * 8 + 10

– Relational Operators
These operators result in either True or
False. These can also be classified as
Boolean operation
FSC 103 NOT FOR SALE PLEASE
• Relational Operators include
greater than (>), less than (<), not equals
to (<>), less than or equals to (<=) etc.

Example of Relational Operators


a = 10, b = 50
If (a < b) then ….
else if (b < a) then…

• Logical Operators
– These include AND, NOT, XOR, OR, EQV

FSC 103 NOT FOR SALE PLEASE


OPERATOR ORDER OF PRECEDENCE
OPERATO OPERATION ORDER OF
R PRECEDENC
E
() Bracket / Parentheses 1

^ Exponential 2
NOT Negation 3
* and / Multiplication & Division 4

\ Integer Division 5

Mod Modulus 6
+ and - Addition or Subtraction 7

<, <=, >, Relational 8


<>
= and <> Equality 9
AND Logical AND
FSC 103 NOT FOR SALE PLEASE10
VB CONTROL STRUCTURE
• Instructions are executed in 3 ways
– Sequentially: one after the other.
– Selection: Choosing an instruction to execute
out a number of alternatives.

• Example
1. If logical expression is true then execute this
Else execute something else
End If

FSC 103 NOT FOR SALE PLEASE


Example of Selection Control
Structure
If (Score > 70) then GP = 5
Else if (Score > 60 AND Score< 70) then GP = 4
Else if (Score > 50 AND Score< 60) then GP = 3
Else if (Score > 40 AND Score< 50) then GP = 2
Else if (Score > 30 AND Score< 40) then GP = 1
Else GP = 0
End If

FSC 103 NOT FOR SALE PLEASE


VB Control Structure
LOOPS
• Looping: Allows repeating an instruction
or set of instructions until a preset
condition is met.
• Looping statements usually have an index
or counter, which is incremented /
decremented during the loop structure.
• After or before each loop the index is
tested to determine if to proceed with the
loop or terminate.
FSC 103 NOT FOR SALE PLEASE
FOR…NEXT LOOP
• For… Next Loop
– For index = 1 to 10 step 1
Print index
Next index

• The For…Next loop is used when the number


of loops to be done is known before hand

FSC 103 NOT FOR SALE PLEASE


DO..LOOP
This is used when the number of loops to be done is not known in advance.

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 example
of PRE-TEST loop statements.

hat is the test condition is tested first before executing the body of the l
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)

These two loop are examples of POST-TEST loop statements,


whereby the body of the loop is executed before test condition is carried

FSC 103 NOT FOR SALE PLEASE


WHILE…WEND LOOP
• While… Wend Loop
– While (a > b)
Print a
b=a*b
Wend

• The While…Wend loop and the Do…loop do


not use index, hence variables MUST be
assigned values before commencing the loop.

FSC 103 NOT FOR SALE PLEASE


LAUNCHING VISUAL BASIC 6
INTEGRATED DEVELOPED INTERFACE

• Click START button


• CLICK PROGRAMS
• CLICK on MS VISUAL
STUDIO 6
• On the NEW PROJECT
dialog, click on
STANDARD EXE.
• Click OPEN

*The above is for


Windows XP / Vista.
Windows 8 varies slightly
FSC 103 NOT FOR SALE PLEASE
THE VB I.D.E Menu Bar
Title Bar

Tool Bar

FSC 103 NOT FOR SALE PLEASE


• Title Bar
– The top most line of the IDE window. It contains the project
name and icon.
– On the LEFT side it contains 3 icons that minimize, maximize
and close the IDE window

• 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.

FSC 103 NOT FOR SALE PLEASE


• Form Designer Window
– The form designer sits right at the center of the VB IDE. It is the heart
and soul of the Visual Basic GUI development process. This is where
you can drag and drop dialog boxes, pictures, and other graphical
elements to complete your project. Familiarize yourself with the form
designer; you will be using it extensively in your programs.

• Properties Explorer
– The properties window allows you to view and edit properties
associated with any particular form or control element.

• Form Layout Window


– This little window helps position the designed form where you want it
in relation to the whole screen

• 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 eachFSC 103 NOT FOR SALE PLEASE
form and control element.
COMMON WINDOWS FORM CONTROLS
VB
• Textbox: is used to accept information entered
by the user during execution or display an
information to the user.

• Label: Primarily used to display text that a


user cannot edit directly by the user during
execution.

• Button: Trigger event(s) or action(s) when


clicked by the user.
FSC 103 NOT FOR SALE PLEASE
Class Example 1

Program to Calculate Area & Circumference of a Circle

FSC 103 NOT FOR SALE PLEASE


• Problem Definition
• Problem Analysis NB: Reporting
– Input & Output should be based
– Procedure on the
– Variables & their data types steps of the
– Buttons & functions Software
• Algorithm & Flowchart Development
Life Cycle (SDLC)
• Implementation
• Documentation

FSC 103 NOT FOR SALE PLEASE


• Problem Definition: A program in MS
Visual Basic to calculate the area &
circumference of a circle.

• Problem Analysis:
– Input = radius of the circle
– Output = area & circumference
– Procedure:
• Area = Pi * radius * radius
• Circumference = 2 * Pi * radius

FSC 103 NOT FOR SALE PLEASE


Modeling & Design

– Variables:
Start
• Dim rad as Integer
• Dim area as Double
Enter • Dim cirm as Double
RADIUS
– Sketch what the
application would
Area = Pi * RADIUS2 Output
Cirmf = 2* Pi * Area & look like
RADIUS Cirmf

Stop

FSC 103 NOT FOR SALE PLEASE


Flowchart
Implementation &
Documentation
• Implementation & programming to be
done in the lab and submitted in your
lab workbooks.
IT WILL BE GRADED AS YOUR TERM
ASSIGNMENT

• Documentation

FSC 103 NOT FOR SALE PLEASE


Class Example 2

Program to Add first 10 Natural Numbers in VB

FSC 103 NOT FOR SALE PLEASE


Program to Add first 10 Numbers
Private Sub Button1_Click(sender As Object, e
As EventArgs) Handles Button1.Click

Dim firstNumber = Val(TextBox1.Text)


Dim lastNumber = Val(TextBox2.Text)
Dim index = firstNumber

Dim result = 0

For index = firstNumber To lastNumber


Step 1
result = result + index
TextBox4.Text = Str(index)
Next index

TextBox3.Text = result

End Sub

FSC 103 NOT FOR SALE PLEASE


End of Class

THANK YOU FOR ATTENDING

FSC 103 NOT FOR SALE PLEASE

You might also like