Java Reference
In-Depth Information
Flowcharts use symbols and special annotations to describe the spe-
cificstepsinprogramflow.Themostcommononesareshownin Figure
1-1 .
FLOWLINES
Connection symbol
Indicates direction of
program flow
RECTANGLE
Processing operations
Data entry. Arithmetic
DIAMOND
Decision
CIRCLE
Termination
symbol
PARALLELOGRAM
Input and output
Figure 1-1 Flowcharting Symbols
Suppose you needed to develop a program to determine when a domes-
tic robot needs to recharge its own batteries. Assume that the robot con-
tains a meter that measures the percent of full charge in its batteries, as
well as a clock that indicates the time of day. The program is to be based
on the following rules:
1. The robot should recharge itself after 5:00 PM.
2. Therobotshouldnotrechargeitselfifthebatteriesaremorethan80%full.
The logic for recharging the robot batteries will first read the internal
clock to determine if it is after 5:00 PM. If so, then it will read the robot's
battery meter to determine if the batteries are less than 80% full. If both
tests are true, then the robot is instructed to plug itself into a wall outlet
and recharge. If not, it is instructed to continue working. The logic can be
expressedinaflowchart,asshownin Figure1-2 .
 
 
Search WWH ::




Custom Search