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

28
Problem-solving with Problem-solving with Computers Computers

Upload: augustus-franklin

Post on 18-Jan-2018

217 views

Category:

Documents


0 download

DESCRIPTION

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

TRANSCRIPT

Page 1: Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of

Problem-solving with Problem-solving with ComputersComputers

Page 2: Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of

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

Page 3: Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of

3

Computer SystemComputer System

Software

HardwareInput Output

A Computer system is a collection of

hardware and software.

Page 4: Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of

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

Page 5: Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of

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.

Page 6: Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of

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 !!

Page 7: Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of

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.

Page 8: Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of

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.

Page 9: Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of

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

Page 10: Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of

10

Problem DefinitionProblem Definition Have a clear understanding the problem

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

Page 11: Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of

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

Page 12: Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of

12

Problem CodingProblem Coding Implementing the solution

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

Program = Algorithm + Data Structure

Page 13: Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of

13

Problem TestingProblem Testing Testing the solution

Structured walk-through Desk checking Sample test data

Page 14: Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of

14

Problem DocumentationProblem Documentation Writing the document

User documentation Program documentation

Program Maintenance

Page 15: Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of

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

Page 16: Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of

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.

Page 17: Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of

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

Page 18: Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of

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

Page 19: Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of

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

Page 20: Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of

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

Page 21: Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of

21

SelectionSelection

if condition then Statement #1 else Statement #2

condition

Statement #2 Statement #1

False True

Page 22: Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of

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

Page 23: Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of

23

Iteration (Repeat Loop)Iteration (Repeat Loop)

repeat Statementsuntil condition

condition

Statements

False

True

Page 24: Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of

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

Page 25: Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of

25

Iteration (While Loop)Iteration (While Loop)

while conditiondo Statements

condition

Statements

False

True

Page 26: Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of

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

Page 27: Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of

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

Page 28: Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of

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