Introduction to problem solving with applications by James Tam | Return to the course web page |
Program description |
Download |
Example of documenting a program |
Simpsons program |
Flowchart (Homer moves forward, greets Bart, Bart greets Homer) |
Linear program (Simpsons) |
Flowchart (Same as previous version except Homer moves and greets at the same time) |
Linear program, simultaneous execution (Simpsons v2) |
Displaying the contents of variables (using 'say' or 'think') |
Variables v1 |
Displaying mixed output (mixing strings and numerical values) when displaying the contents of variables |
Variables v2 |
Branching (if-else). Program asks for the user's name and it reacts differently for one particular user. |
If-Else V1 |
Branching (if-else). Identical to the previous program except that there is an additional instruction after the branch that's always executed. |
If-Else V2 |
Branching and generating random numbers |
Dice simulation |
Branching (logical OR): a program to determine if a candidate should be hired |
Hiring program (Alice program)Hiring program (Flowchart) |
Branching (logical AND): a program to determine if an existing employee should be fired |
Firing program (Alice program)Hiring program (Flowchart) |
Multiple successive branches (camel's appearance changes depending upon the answer to the questions, the result of both questions are independent) |
Multiple branches |
Nested branches (camel's appearance changes again but now the answer to one question determines if the other question is asked) |
Nested branches |
Simple loops (an evil ninja jumps up and down 5 times) uses the 'loop' instruction |
Loop (Alice program) |
More advanced loop, the number of jumps is determined by user input, uses the 'while' instruction |
While loop (Alice program)While loop (Flowchart) |
A quick summary of the flowcharting symbols that you new to know for this class: Symbols |