problem-solving with computers. 2outline computer system 5 steps for producing a computer program ...

Post on 18-Jan-2018

217 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

DESCRIPTION

3 Computer System Software Hardware InputOutput  A Computer system is a collection of hardware and software.

TRANSCRIPT

Problem-solving with Problem-solving with ComputersComputers

2

OutlineOutlineComputer System

5 Steps for producing a computer program

Structured program and programming 3 types of control structure

Algorithm Tools for describing an algorithm Examples of algorithm and programs

3

Computer SystemComputer System

Software

HardwareInput Output

A Computer system is a collection of

hardware and software.

4

Computer SystemComputer System

Hardware the electric, electronic, and mechanical

equipment that makes up a computer

Software the series of instructions that tells the

hardware how to perform tasks

5

Computer SystemComputer System Hardware : requires a series of instructions to

carry out its processing function.

Software : a group of instructions (computer program) which command a computer to take action and to make decision.

Without software, hardware is useless; hardware needs the instructions provides by software to process data into information.

6

Computer Program Computer Program (Software)(Software)

A program is a sequence of instructions suitable for processing by a computer

Programs are written for controlling the computer hardware

o Instructions in a program tell the hardware to perform a task

for solving problems.

Without software, the hardware doesn’t know what to do !!

7

Computer SystemComputer System

Algorithm describe the method in a sequence of steps to

get a computer to perform a task.

An Algorithm must be translated into a program by coding in a programming

language.

8

Computer Program Computer Program (Software)(Software)

The activities of expressing an algorithm of a problem and translating the algorithm as a program is called programming.

The most fundamental concepts of computer science is programming and algorithm.

9

5 Major Steps5 Major Steps for Producing a for Producing a Computer ProgramComputer Program

Problem Definition Understanding the problem

Problem Design Proposing the solution

Problem Coding Implementing the solution

Problem Testing Testing the solution

Problem Documentation Writing the document

10

Problem DefinitionProblem Definition Have a clear understanding the problem

What we want to do specify objectives specify the desired input and output

11

Problem DesignProblem Design Proposing the solution

Top-down design with modularity approach using hierarchy chart

Input/output and data structure design Algorithm design with certain tools

o Pseudocodeo Flowchart

12

Problem CodingProblem Coding Implementing the solution

Write (code) the program from algorithm by using selected programming language

Program = Algorithm + Data Structure

13

Problem TestingProblem Testing Testing the solution

Structured walk-through Desk checking Sample test data

14

Problem DocumentationProblem Documentation Writing the document

User documentation Program documentation

Program Maintenance

15

Structure Program and Structure Program and ProgrammingProgramming

Technique for organizing and coding computer programs Hierarchy of modules is used

Single entry Single exit point Control is passed downward through the

structure without unconditional branches to higher levels of the structure

16

Structure Program and Structure Program and ProgrammingProgramming

Module A self-contained activities that contributes a

specific subtask.

The overall task is done in a logical order of the hierarchy of the subtasks.

17

Example of Top-down Design Example of Top-down Design (with Modularity approach using a hierarchy chart)

Payroll System

Input Payment Processing Output

Compute Pay Compute Payroll Deduction

Regular Pay

Overtime Pay Payroll

SavingTax

18

Problem Solving with Problem Solving with ComputerComputer

Problem

Solution in a computer program

Solution in a algorithm form

Difficult in solving big problem

Problem solving phase

Implementation phase

19

Structure Program and Structure Program and ProgrammingProgramming

3 types of control flow (structure) Sequence Selection or branching Iteration or looping

Explain on the blackboard

20

SequenceSequence

Statement #1Statement #2Statement #3

read X

read Y

Z = X + Y

print (“The sum of X and Y is ”, Z)

ExampleExample

Statement #1

Statement #2

Statement #3

21

SelectionSelection

if condition then Statement #1 else Statement #2

condition

Statement #2 Statement #1

False True

22

SelectionSelection

read X

read Y

if if ( X > Y ) then then print (“ X is greater than Y”)

elseelse print (“ Y is greater than X”)

ExampleExample

if condition then Statement #1 else Statement #2

23

Iteration (Repeat Loop)Iteration (Repeat Loop)

repeat Statementsuntil condition

condition

Statements

False

True

24

Iteration (Repeat Loop)Iteration (Repeat Loop)

repeat Statementsuntil condition

read X

read Y

repeat repeat print X

X = X+1

untiluntil (X >Y)

ExampleExample

25

Iteration (While Loop)Iteration (While Loop)

while conditiondo Statements

condition

Statements

False

True

26

Iteration (While Loop)Iteration (While Loop)

read X

read Y

while while (X<=Y)

do do print X

X = X+1

ExampleExample

while conditiondo Statements

27

Iteration (For Loop)Iteration (For Loop)

for i = 1 to n do Statements

i <= ni <= n

Statements

False

1 i

i = i + 1

True

28

Iteration (For Loop)Iteration (For Loop)

for i = 1 to n do Statements

read X

read Y

for for i = 1 to X

do do print (“The value of i is ”, i)

ExampleExample

top related