Symbols · control structures · Java mapping · common mistakes
| Shape | Name | Java |
|---|---|---|
| Terminal: start/end | main begins/ends | |
| Input/Output | sc.nextInt(), println | |
| Process | = ++ += math | |
| Decision: 2 exits (T/F) | if, loop tests | |
| On-page connector | joins lines | |
| Off-page connector | continues on next page | |
| Predefined process | method call | |
| Preparation (optional) | for setup |
if, if-else, else if, switch.while, for, do-while.if (n < 0) { n = -n; } // if: one path
if (score >= 75) println("Pass"); // if-else:
else println("Fail"); // exactly one runs
if (s >= 90) ... // else-if ladder:
else if (s >= 80) ... // False -> next diamond
else ... // first True wins
switch: one diamond per case, default = last False path. No break means it falls through to the next case.
int i = 1; // initialize (before loop)
while (i <= 5) { // test = diamond
println(i); // body
i++; // update, then back to test
}
for (int i = 1; i <= 5; i++) { ... } // same shape
do { // body FIRST
...
} while (x < 5); // test LAST (note the ;)
| Loop | Test | Min runs |
|---|---|---|
while | pre-test (before body) | 0 |
for | pre-test (before body) | 0 |
do-while | post-test (after body) | 1 |
for).-1.main → Startsc.next…() / println → parallelogram=, ++, math → rectangleif / loop condition → diamondmain → Endprintln. It's Output (parallelogram).sum = 0 inside the loop (it resets every pass).