Date post: | 22-Jan-2018 |
Category: |
Education |
Upload: | gabriela-technoteacher |
View: | 1,518 times |
Download: | 0 times |
UNIT 2_ programmingflow diagrams
exercises
Technologies 1 ESOgabriela-teacher.blogspot.com
WHAT’S A FLOW DIAGRAM?
A flow diagram is a graphicrepresentation of a sequence.
The flow diagram of a programis the graphic representationof the sequence of actionsthat the computer performswhen we run the program.
This is a very complex example of a flow diagram
EXERCISES
In the next slides, you’ll read a different proposalsof sequences of programs.
You will work cooperatively to work out the flowdiagrams of those sequences. You have to use the symbols we’ve studied in class
Then, you’ll see the solutions and the teacher willexplain.
This is also useful when you study at home.
PROGRAM 1
When the program starts, the computer asks theuser for two numbers (a and b).
The user enters the two numbers, the computeradds them up, and shows the user the result…
What’s this program flowdiagram???
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, thecomputer asks the user their age.
If the user is under 18, the computer says “Sorry, youcan’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 differentnumbers.
When the user enters the two numbers, thecomputer compares them and tells the userwhich is the highest number.
What’s this program flowdiagram???
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, thecomputer 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 theuser which is the highest number.
What’s this program flowdiagram???
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 flowdiagram???
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?
no
yes
CHANGE
BULB
REPAIR
LAMP
Does it
work
now?
yes
no
Does 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. Ifnot, ask the user to re-write it. If it’s correct, the app opens. The maximum number of tries theuser 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 thebus. When you arrive to the bus station, you only take the bus if it’s right there or if it’sapproaching 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, theprogram divides the number per 10 and shows the result. If the number is lower, the computersays “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 between6 pm and 9 pm.