Вы находитесь на странице: 1из 9

University of RIzal System, Morong, Rizal Prof. Michael B.

Francisco, MIT

Visual Basic 2012 – Chapter 1 Communicating with the


Computer
• Machine language – low level, hard for
humans to understand
• Visual Basic – high level, understood by
humans, consists of instructions such as
Click, If, and Do

An Introduction to Computers
and Problem Solving

Programming and
Compiler Complicated Tasks
• A compiler translates a high-level • Tasks are broken down into instructions
language into machine language. that can be expressed by a programming
• The Visual Basic compiler points out language
certain types of errors during the • A program is a sequence of instructions
translation process. • Programs can be only a few instructions
or millions of lines of instructions
University of RIzal System, Morong, Rizal Prof. Michael B. Francisco, MIT

All Programs Have in


Common: Hardware and Software
• Take data and manipulate it to produce a • Hardware – the physical components of
result the computer
• Input – Process – Output • Central processing unit
• Input – from files, the keyboard, or other • Disk drive
input device • Monitor
• Output – usually to the monitor, a printer, or • Software – The instructions that tell the
a file computer what to do

Programmer and User Problem Solving


• Programmer – the person who solves the • Developing the solution to a problem
problem and writes the instructions for • Algorithm – a step by step series of
the computer instructions to solve a problem
• User – any person who uses the
program written by the programmer
University of RIzal System, Morong, Rizal Prof. Michael B. Francisco, MIT

Visual Basic 2012 XP vs Vista vs Win 7 vs Win 8


• BASIC originally developed at Dartmouth
in the early 1960s
• Visual Basic created by Microsoft in 1991
• Visual Basic 2012 is similar to original
Visual Basic, but more powerful
• Visual Basic release date – September
2012
XP Vista Windows 7 Windows 8

Program Development Cycle Terminology


• Performing a Task on the Computer A computer program may also be called:
• Project
• Program Planning
• Application
• Solution
University of RIzal System, Morong, Rizal Prof. Michael B. Francisco, MIT

Performing a Task on the


Program Development Cycle Computer
• Software refers to a collection of • Determine Output
instructions for the computer • Identify Input
• The computer only knows how to do • Determine process necessary to turn
what the programmer tells it to do given Input into desired Output
• Therefore, the programmer has to know
how to solve problems

Problem-Solving: Approach Pictorial representation of the


Like Algebra Problem Problem Solving Process
• How fast is a car traveling if it goes 50
miles in 2 hours?
• Output: a number giving the speed in
miles per hour
• Input: the distance and time the car has
traveled
• Process: speed = distance / time
University of RIzal System, Morong, Rizal Prof. Michael B. Francisco, MIT

Program Planning Program Planning (continued)


• A recipe is a good example of a plan • Always have a plan before trying to
• Ingredients and amounts are write a program
determined by what you want to • The more complicated the
bake problem, the more complex the
• Ingredients are input plan must be
• The way you combine them is the
• Planning and testing before coding
processing
saves time
• What is baked is the output

Program Development Cycle


Program Development Cycle (continued)
1. Analyze: Define the problem. 4. Code: Translate the algorithm into
2. Design: Plan the solution to the a programming language.
5. Test and debug: Locate and
problem. remove any errors in the program.
3. Choose the interface: Select the
6. Complete the documentation:
objects (text boxes, buttons, etc.).
Organize all the materials that
describe the program.
University of RIzal System, Morong, Rizal Prof. Michael B. Francisco, MIT

Programming Tools Algorithm


Three tools are used to convert algorithms A step-by-step series of instructions for
into computer programs: solving a problem (a recipe is an example
• Flowchart - Graphically depicts the logical of an algorithm).
steps to carry out a task and shows how the
steps relate to each other.
• Pseudocode - Uses English-like phrases
with some Visual Basic terms to outline the
program.
• Hierarchy chart - Shows how the different
parts of a program relate to each other.

Problem Solving Example Algorithm


• How many stamps should you use when 1. Request the number of sheets of paper;
mailing a letter? call it Sheets. (input)
• One rule of thumb is to use one stamp 2. Divide Sheets by 5. (processing)
for every five sheets of paper or fraction 3. Round the quotient up to the next
thereof. highest whole number; call it Stamps.
(processing)
4. Reply with the number Stamps. (output)
University of RIzal System, Morong, Rizal Prof. Michael B. Francisco, MIT

Flowchart Flowchart Symbols


Graphically depicst the logical steps to
carry out a task and show how the steps
relate to each other.

Flowchart Symbols Flowchart


(continued) Example

41
University of RIzal System, Morong, Rizal Prof. Michael B. Francisco, MIT

Pseudocode Pseudocode Example


Uses English-like phrases with some Determine the proper number of stamps for
Visual Basic terms to outline the task. a letter
Read Sheets (input)
Set the number of stamps to Sheets / 5
(processing)
Round the number of stamps up to the
next whole number (processing)
Display the number of stamps (output)

Hierarchy Chart Hierarchy Charts Example


• Shows how the different parts of a program
relate to each other
Hierarchy charts are also called
• structure charts
• HIPO (Hierarchy plus Input-Process-Output)
charts
• top-down charts
• VTOC (Visual Table of Contents) charts
University of RIzal System, Morong, Rizal Prof. Michael B. Francisco, MIT

Divide-and-Conquer Method Statement Structures


• Used in problem solving – take a large • Sequence – execute instructions from
problem and break it into smaller one line to the next without skipping
problems over any lines
• Solve the small problems first • Decision - if the answer to a question is
“Yes” then one group of instructions is
executed. If the answer is “No,” then
another is executed
• Looping – a series of instructions are
executed repeatedly

Sequence
Flow Chart Decision Flow Chart

48

Вам также может понравиться