from real problem to computer program? you now what you want to do, but how to make it with a...

23
From real problem to From real problem to Computer program? Computer program? You now what You want to do, but how to make it with a C-program?

Upload: hector-gibson

Post on 13-Jan-2016

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: From real problem to Computer program? You now what You want to do, but how to make it with a C-program?

From real problem to From real problem to Computer program?Computer program?

You now what You want to do, but how to make it with a C-program?

Page 2: From real problem to Computer program? You now what You want to do, but how to make it with a C-program?

Morning routine

Structure diagramStructure diagram

”Morningwhile has gold in mouthd”

Get dressed Eat breakfast Go to school

TimeTimeDivisionDivision

By 2IT Data students …

Page 3: From real problem to Computer program? You now what You want to do, but how to make it with a C-program?

Sequence (order in time)Sequence (order in time)

Get dressed Eat breakfast Go to school

Morning routine

8:00 am 8:02 am 8:05 am Time

Sequence

Sequence parts

Page 4: From real problem to Computer program? You now what You want to do, but how to make it with a C-program?

Structure diagramStructure diagram

”Morningwhile has gold in mouthd”

Find clothes Put clothes on

Morning routine

Get dressed Eat breakfast Go to school

DivisionDivisionTimeTime

Take fromwash basket

Ask girlfriendwhere clothes are

Page 5: From real problem to Computer program? You now what You want to do, but how to make it with a C-program?

SelectionSelection

Blue Pink White

What colour on your socks?

If blue existsIf blue doesn’t exist,but pink does Else

Selection

Selection parts

Page 6: From real problem to Computer program? You now what You want to do, but how to make it with a C-program?

Structure diagramStructure diagram

”Morningwhile has gold in mouthd”

Many glasses of beer

One glassof beer

DivisionDivisionTimeTime

Morning routine

Take fromwash basket

Ask girlfriendwhere clothes are

Find clothes Put clothes on

Get dressed Eat breakfast Go to school

Page 7: From real problem to Computer program? You now what You want to do, but how to make it with a C-program?

Iteration (repetition)Iteration (repetition)

Many glassesof beer

One beer

Drink beer (lightbeer)

As long as you’re thirsty

Iteration

Iteration part

Page 8: From real problem to Computer program? You now what You want to do, but how to make it with a C-program?

Structure diagramStructure diagram

”Morningwhile has gold in mouthd”

DivisionDivisionTimeTime

Take a cab Run

One step

Morning routine

Take fromwash basket

Ask girlfriendwhere clothes are

Find clothes Put clothes on

Get dressed Eat breakfast Go to school

Many glasses of beer

One glassof beer

Page 9: From real problem to Computer program? You now what You want to do, but how to make it with a C-program?

Flow chartFlow chart

Move foot one step

Run

Go to school

Eat one pancake

Eat breakfast

Put on the clothes

Ask girl/boyfriendGet from laundrybasket

Search clothes

Get dressed

Morning route

IF you find basket

WHILE pancakes <> 0

Take a cab

IF money = 0

ELSE

ELSE

WHILE distance to school <> 0

Flowcharts are one dimensional. They are used when you have to describe exactly how the code is processed.

The Structure diagram is easier to follow.

Page 10: From real problem to Computer program? You now what You want to do, but how to make it with a C-program?

CrossingCrossing

A

B

Imagine driving in car B, just behind another car A.You come to a crossing.How will you know which direction it will chose?

Car A has to make a selection

Page 11: From real problem to Computer program? You now what You want to do, but how to make it with a C-program?

CrossingCrossing a selection of directionsa selection of directions

How can you see in which direction the car in front of you will choose?

Crossing

Green signal

STOP DRIVE

Red signal

Left blinker Right blinkerNo blinker

Drive left Straight ahead Drive right

Selection

Page 12: From real problem to Computer program? You now what You want to do, but how to make it with a C-program?

Marriage - a selection?Marriage - a selection?

Marry girl

Young man´sfuture choice

not JSP

Page 13: From real problem to Computer program? You now what You want to do, but how to make it with a C-program?

SelectionpartsSelectionparts

Young man´s future choice

• A selection must contain at least two selection components. If It only contains one there is no selection.

Marry girl Be free!!

Like this!

Page 14: From real problem to Computer program? You now what You want to do, but how to make it with a C-program?

Al Bundy?Al Bundy?

Young man´s future choice

We know the end…? Peg.. - make dinner!

Marry girl

It is however possible to leave a selection component empty.

Page 15: From real problem to Computer program? You now what You want to do, but how to make it with a C-program?

Rules of ChristmasRules of Christmas

Checks hisslade

Santa ClausX-mas day

Gives onegift

*

While gifts not 0

not JSP

Page 16: From real problem to Computer program? You now what You want to do, but how to make it with a C-program?

Santa changed his mindSanta changed his mind• Parts connected to the same component must be of similar type

Santa ClausX-mas day

Checks hisslade

First

Hands out gifts

Last

This is CORRECT!! Gives one

gift

While gifts not 0

*

Page 17: From real problem to Computer program? You now what You want to do, but how to make it with a C-program?

Paint house - an iterationPaint house - an iteration

PaintHouse

Get paint*While painter not satisfied with color

Paint withBrush

*

While entire house not painted

not JSP

Page 18: From real problem to Computer program? You now what You want to do, but how to make it with a C-program?

Now you can begin to paintNow you can begin to paint

Get paint Begin to

paint

Paint

House

• An iteration can only contain one repeated component

Get onecan of paint

Paint with

Brush

* *

While painter not satisfied with color

While entire house not painted

Iterations

Iterationcomponents

OK !

Page 19: From real problem to Computer program? You now what You want to do, but how to make it with a C-program?

JSP-editorJSP-editor

Henrik Engström JSP-editor

Page 20: From real problem to Computer program? You now what You want to do, but how to make it with a C-program?

Generate CGenerate C

Page 21: From real problem to Computer program? You now what You want to do, but how to make it with a C-program?

Web-QuizWeb-Quiz

Page 22: From real problem to Computer program? You now what You want to do, but how to make it with a C-program?

Web-QuizWeb-Quiz

Page 23: From real problem to Computer program? You now what You want to do, but how to make it with a C-program?

Good luck with your Good luck with your exercises!exercises!