flow diagrams exercises

14
UNIT 1_ programming flow diagrams exercises Technologies 1 ESO gabriela-teacher.blogspot.com

Upload: gabriela-technoteacher

Post on 08-Jan-2017

516 views

Category:

Education


0 download

TRANSCRIPT

UNIT 1_ programmingflow diagrams

exercisesTechnologies 1 ESO

gabriela-teacher.blogspot.com

WHAT’S A FLOW DIAGRAM?A flow diagram is a graphic

representation of a sequence.

The flow diagram of a program is the graphic representation of the sequence of actions that the computer performs when we run the program.

This is a very complex example of a flow diagram

EXERCISESIn the next slides, you’ll read a different proposals

of sequences of programs.You will work cooperatively to work out the flow

diagrams of those sequences. You have to use the symbols we’ve studied in class

Then, you’ll see the solutions and the teacher will explain.

This is also useful when you study at home.

PROGRAM 1When the program starts, the computer asks the

user for two numbers (a and b).The user enters the two numbers, the computer

adds them up, and shows the user the result…

What’s this program flow diagram???

START

END

COMPUTER OUTPUTS MESSAGE: “Write two numbers”

USER INPUTS two numbers

a, b

COMPUTER ADDS a + b = c

COMPUTER OUTPUTS : “The

result is c”

PROGRAM 2 This program is a game. When the game starts, the

computer asks the user their age.If the user is under 18, the computer says “Sorry, you

can’t play” and the game closes.If the user is over 18, the computer says “Welcome”,

the first level opens and the user plays. After 20 minutes, the game closes automatically.

What’s this program flow diagram???

START

END

COMPUTER OUTPUTS

MESSAGE: “How old are you?”

USER INPUTS age (a)

GAME OPENS

COMPUTER OUTPUTS : “Sorry, you can’t

play”

a > 18 ?yes

noCOMPUTER OUTPUTS: “Welcome”

Wait 20 minutes

PROGRAM 3 A program that asks the user for two different

numbers.When the user enters the two numbers, the

computer compares them and tells the user which is the highest number.

What’s this program flow diagram???

START

END

COMPUTER OUTPUTS

MESSAGE: “Write two different

numbers”

USER INPUTS a, b

a > b ?yes

noCOMPUTER OUTPUTS: “a is the biggest number” COMPUTER

OUTPUTS: “b is the biggest number”

PROGRAM 4 A program that asks the user for two different

numbers.When the user enters the two numbers, the

computer first makes sure the numbers are different.

If they are the same, it asks the user again.If they are different, it compares them and tells the

user which is the highest number.

What’s this program flow diagram???

START

END

COMPUTER OUTPUTS

MESSAGE: “Write two different

numbers”

USER INPUTS a, b

a = b ?yes

no

COMPUTER OUTPUTS: “a is the biggest number”

COMPUTER OUTPUTS: “b is the biggest number”

a > b ?yes

no

REAL LIFE SITUATION 1The sequence of steps when you find out that a

lamp doesn’t work.

What’s this situation flow diagram???

START: Lamp

doesn’t work

END 1: PROBLE

M SORTED!

no

yes

no

Is it plugged in?

yes

PLUG IN

Is the bulb burned

out?

Does it work now?

noyes

CHANGE BULB

REPAIR LAMP

Does it work now?

yes

noDoes it work now?

yes

END 2: Buy a new

lamp

no

EXTRA WORKIf you want to learn more, you can try to design the

flow diagrams of these programs:PROGRAM 5 An app that ask the user for a password. The app checks if the password is correct. If

not, ask the user to re-write it. If it’s correct, the app opens. The maximum number of tries the user has is 3. After 3 failures, the app closes saying “Sorry, try again later”.

REAL LIFE SITUATION 2 Your home is at walking distance from school, but you prefer to wait for the bus. When you arrive to the bus station, you only take the bus if it’s right there or if it’s approaching the bus stop. If you can’t see the bus, you walk to school.

PROGRAM 6 A program that asks the user for a number. If the number is higher than 10, the program divides the number per 10 and shows the result. If the number is lower, the computer says “Sorry, you number must be higher than 10” and ask the user for a number again.

REAL LIFE SITUATION 3 The sequence of actions you perform in a normal school afternoon between 6 pm and 9 pm.