ACSE 2006 8 th Conference
description
Transcript of ACSE 2006 8 th Conference
![Page 1: ACSE 2006 8 th Conference](https://reader036.fdocuments.in/reader036/viewer/2022062500/56815015550346895dbdfb15/html5/thumbnails/1.jpg)
ACSE 20068th Conference
The Iconic Programmer
Stephen Chen
![Page 2: ACSE 2006 8 th Conference](https://reader036.fdocuments.in/reader036/viewer/2022062500/56815015550346895dbdfb15/html5/thumbnails/2.jpg)
ACSE -- The Iconic Programmer 2
Overview
Actual slides from first three weeks Want students to focus on
programming concepts rather than (JAVA) syntax
Want students to learn to think in structures (i.e. problem solve)
![Page 3: ACSE 2006 8 th Conference](https://reader036.fdocuments.in/reader036/viewer/2022062500/56815015550346895dbdfb15/html5/thumbnails/3.jpg)
ACSE -- The Iconic Programmer 3
Structured Programming
Focus on processes – focus on actions 3 structures of structured programming
SequencePerform an action
BranchSelect an action (or no action)
LoopRepeat an action
![Page 4: ACSE 2006 8 th Conference](https://reader036.fdocuments.in/reader036/viewer/2022062500/56815015550346895dbdfb15/html5/thumbnails/4.jpg)
ACSE -- The Iconic Programmer 4
Each structure has an icon
Program by assembling icons
Iconic Programmer
![Page 5: ACSE 2006 8 th Conference](https://reader036.fdocuments.in/reader036/viewer/2022062500/56815015550346895dbdfb15/html5/thumbnails/5.jpg)
ACSE -- The Iconic Programmer 5
Sequence
Standard operation of a computer Actions are performed in sequence
First actionSecond action…Last action
Program runs same way each time
![Page 6: ACSE 2006 8 th Conference](https://reader036.fdocuments.in/reader036/viewer/2022062500/56815015550346895dbdfb15/html5/thumbnails/6.jpg)
ACSE -- The Iconic Programmer 6
Actions
ActionManipulate data
Iconic ProgrammerDeclareAssignOutput
![Page 7: ACSE 2006 8 th Conference](https://reader036.fdocuments.in/reader036/viewer/2022062500/56815015550346895dbdfb15/html5/thumbnails/7.jpg)
ACSE -- The Iconic Programmer 7
Declarations
A computer needs to allocate storage space for all data that it manipulatesDeclaration gives a meaningful name to
the data element/storage space Iconic Programmer
Only integer data elementsGive name in text box
![Page 8: ACSE 2006 8 th Conference](https://reader036.fdocuments.in/reader036/viewer/2022062500/56815015550346895dbdfb15/html5/thumbnails/8.jpg)
ACSE -- The Iconic Programmer 8
Assignments
Once the computer has a storage space, it can store/change data in that space
Iconic ProgrammerRandom valueResult of mathematical expressionUser input
![Page 9: ACSE 2006 8 th Conference](https://reader036.fdocuments.in/reader036/viewer/2022062500/56815015550346895dbdfb15/html5/thumbnails/9.jpg)
ACSE -- The Iconic Programmer 9
Mathematical Expressions
value = value +1 (math)The value is equal to the value plus one Impossible mathematically
value = value + 1 (computers)The storage space for value will become
the previous contents plus one Actions: perform math, perform storage
![Page 10: ACSE 2006 8 th Conference](https://reader036.fdocuments.in/reader036/viewer/2022062500/56815015550346895dbdfb15/html5/thumbnails/10.jpg)
ACSE -- The Iconic Programmer 10
Output
When computer is done with program (or during debugging), we may want to see the result – what is in a storage space
Iconic ProgrammerValue in storage spaceText information (nominally stored)
![Page 11: ACSE 2006 8 th Conference](https://reader036.fdocuments.in/reader036/viewer/2022062500/56815015550346895dbdfb15/html5/thumbnails/11.jpg)
ACSE -- The Iconic Programmer 11
Sample Program
Output the double and triple of an inputDeclare a storage spaceAssign an input value to the storage spaceDeclare a second storage spaceAssign double the input to this spaceOutput the value in the second spaceAssign triple the input to this spaceOutput the value in the second space
![Page 12: ACSE 2006 8 th Conference](https://reader036.fdocuments.in/reader036/viewer/2022062500/56815015550346895dbdfb15/html5/thumbnails/12.jpg)
ACSE -- The Iconic Programmer 12
Branching allows a program to make decisions
Diamonds represent conditionsTwo outgoing paths from conditionPaths (with sequences) can be skipped
Branching
![Page 13: ACSE 2006 8 th Conference](https://reader036.fdocuments.in/reader036/viewer/2022062500/56815015550346895dbdfb15/html5/thumbnails/13.jpg)
ACSE -- The Iconic Programmer 13
Example of Branching
Program specificationMake withdrawal if funds are sufficient
Program actionsCheck account balance and withdraw
amountMake withdrawal
Need to make withdrawal optional
![Page 14: ACSE 2006 8 th Conference](https://reader036.fdocuments.in/reader036/viewer/2022062500/56815015550346895dbdfb15/html5/thumbnails/14.jpg)
ACSE -- The Iconic Programmer 14
Decisions
Branching selects from two paths Two paths two states
true (yes)false (no)
Diamond contains a condition A condition is a true-false question
![Page 15: ACSE 2006 8 th Conference](https://reader036.fdocuments.in/reader036/viewer/2022062500/56815015550346895dbdfb15/html5/thumbnails/15.jpg)
ACSE -- The Iconic Programmer 15
Relational Operators
How to turn integers into true/false?Greater thanLess thanEqual toNot equal toGreater than or equal toLess than or equal to
![Page 16: ACSE 2006 8 th Conference](https://reader036.fdocuments.in/reader036/viewer/2022062500/56815015550346895dbdfb15/html5/thumbnails/16.jpg)
ACSE -- The Iconic Programmer 16
Compound Conditions
Allow us to put two (or more) sub-conditions into a conditionANDOR
![Page 17: ACSE 2006 8 th Conference](https://reader036.fdocuments.in/reader036/viewer/2022062500/56815015550346895dbdfb15/html5/thumbnails/17.jpg)
ACSE -- The Iconic Programmer 17
AND
The expression is TRUE if and only if both input variables are TRUE
TRUE
1
FALSE
0
TRUE
1
TRUE
1
FALSE
0
FALSE
0
FALSE
0
FALSE
0
![Page 18: ACSE 2006 8 th Conference](https://reader036.fdocuments.in/reader036/viewer/2022062500/56815015550346895dbdfb15/html5/thumbnails/18.jpg)
ACSE -- The Iconic Programmer 18
OR
The expression is TRUE if either input variable is TRUE
TRUE
1
FALSE
0
TRUE
1
TRUE
1
TRUE
1
FALSE
0
TRUE
1
FALSE
0
![Page 19: ACSE 2006 8 th Conference](https://reader036.fdocuments.in/reader036/viewer/2022062500/56815015550346895dbdfb15/html5/thumbnails/19.jpg)
ACSE -- The Iconic Programmer 19
Inclusive and Exclusive OR
Computers use inclusive ORStop the bus if passengerA OR
passengerB wants to get off Exclusive OR is different
You can get $1000 cash back or 0% financing
![Page 20: ACSE 2006 8 th Conference](https://reader036.fdocuments.in/reader036/viewer/2022062500/56815015550346895dbdfb15/html5/thumbnails/20.jpg)
ACSE -- The Iconic Programmer 20
Two Branches
Did you roll a doublet?die1 == die2 double moveNormal move
![Page 21: ACSE 2006 8 th Conference](https://reader036.fdocuments.in/reader036/viewer/2022062500/56815015550346895dbdfb15/html5/thumbnails/21.jpg)
ACSE -- The Iconic Programmer 21
Multiple Branches
What is your grade classification?>= 80 honours>= 60 passNot pass
![Page 22: ACSE 2006 8 th Conference](https://reader036.fdocuments.in/reader036/viewer/2022062500/56815015550346895dbdfb15/html5/thumbnails/22.jpg)
ACSE -- The Iconic Programmer 22
Looping
In Sequence and Branching, each action is performed at most once
Looping allows certain actions to be repeated
Keeps programs from getting large and unmanageable
![Page 23: ACSE 2006 8 th Conference](https://reader036.fdocuments.in/reader036/viewer/2022062500/56815015550346895dbdfb15/html5/thumbnails/23.jpg)
ACSE -- The Iconic Programmer 23
Example of Looping
Program specificationTake user inputs until they guess correctly
ProgramDeclare and initialize numberDeclare guess Input and compare guess Input and compare guess…
![Page 24: ACSE 2006 8 th Conference](https://reader036.fdocuments.in/reader036/viewer/2022062500/56815015550346895dbdfb15/html5/thumbnails/24.jpg)
ACSE -- The Iconic Programmer 24
Looping Icon
Loops have same components as branches
Condition selects one of two pathsOptional path “loops back” to condition
![Page 25: ACSE 2006 8 th Conference](https://reader036.fdocuments.in/reader036/viewer/2022062500/56815015550346895dbdfb15/html5/thumbnails/25.jpg)
ACSE -- The Iconic Programmer 25
Java syntax – branches
Basic shell
if (/*boolean expression*/)
{
// conditional statements
}
![Page 26: ACSE 2006 8 th Conference](https://reader036.fdocuments.in/reader036/viewer/2022062500/56815015550346895dbdfb15/html5/thumbnails/26.jpg)
ACSE -- The Iconic Programmer 26
Java syntax – exclusive branches
if (/*boolean expression*/)
{
// conditional statements
}
else
{
// default statements
}
![Page 27: ACSE 2006 8 th Conference](https://reader036.fdocuments.in/reader036/viewer/2022062500/56815015550346895dbdfb15/html5/thumbnails/27.jpg)
ACSE -- The Iconic Programmer 27
Java syntax – multiple branches
if (/*boolean expression*/){
// conditional statements} else if (/*boolean expression*/){
// more conditional statements}
![Page 28: ACSE 2006 8 th Conference](https://reader036.fdocuments.in/reader036/viewer/2022062500/56815015550346895dbdfb15/html5/thumbnails/28.jpg)
ACSE -- The Iconic Programmer 28
Java syntax – loops
Basic shell
while (/*boolean expression*/)
{
// repeatable statements
}
![Page 29: ACSE 2006 8 th Conference](https://reader036.fdocuments.in/reader036/viewer/2022062500/56815015550346895dbdfb15/html5/thumbnails/29.jpg)
ACSE -- The Iconic Programmer 29
Common Error
Decision to loop does not require a branch
Decisions are not structures Branches - selected actions Loops - repeated actions
![Page 30: ACSE 2006 8 th Conference](https://reader036.fdocuments.in/reader036/viewer/2022062500/56815015550346895dbdfb15/html5/thumbnails/30.jpg)
ACSE -- The Iconic Programmer 30
Sample Program – Telephone Banking
Write a program that implements an ATM interface1 – get balance2 – deposit3 – withdraw9 – end session
What are the key structures?