notes/education/software development/ECE1400/Flowcharts and Pseudocode.md
2024-08-31 14:39:50 -06:00

110 lines
2.1 KiB
Markdown

# Banana Cake
## Instructions
1. Assume an action set of {add \<ingredient>, stir, bake, cool}. Draw a flowchart, using the paradigm discussed in class, to show the process of baking a banana cake. Use Google to find a typical list of ingredients.
2. Represent the flowchart from problem 1 as pseudocode.
## Flowchart
```d2
vars: {
d2-config: {
dark-theme-id: 200
}
}
grid-columns: 3
begin: {
shape: oval
# near: top-left
}
begin -> add 3c flour\
-> add 1 1/2 tsp baking soda\
-> add 1/2 tsp cinnamon\
-> add 1/2 tsp salt\
-> stir\
-> add 3 mashed bananas\
-> add 1 tsp lemon juice\
-> stir again\
-> add 3 eggs\
-> add 2tsp vanilla extract\
-> stir a final time\
-> bake @ 350f for 50 min\
-> let cool for 1 hour\
-> end
end: {
shape: oval
# near: bottom-right
}
```
## Pseudocode
```c
/**************************************
* Function Title: BakeBananaCake
*
* Summary: Bake a banana cake
*
* Inputs: none
* Outputs: none
**************************************
* Pseudocode
*
* Begin
* Add 3c flour
* Add 1 1/2 tps baking soda
* Add 1/2 tsp cinnamon
* Add 1/2 tsp salt
* Stir
* Add 3 mashed bananas
* Add 1 tsp lemon juice
* Stir
* Add 3 eggs
* Add 2tsp vanilla extract
* Stir a final time
* Bake @ 350F for 50 min
* Cool for 1 hour
* End
**************************************/
```
# Walking
## Instructions
3. Assume an action set of {walk \<value> steps, turn to \<value> degrees}. Draw a flowchart showing a shady path and a sunny path to get from the west doors of the Engineering Building to the south-east doors of the TSC. Pick a meaningful “if” condition to select one of the two paths. Use real-world data in your design.
4. Represent the flowchart from problem 3 as pseudocode.
%%
Assuming a step distance of 2.5 feet.
Sunny path:
Total distance: 1922.59ft
769 steps total
Shady path:
Turn to 270 degrees
Walk 73 steps
Turn to 0 degrees
Walk 94 steps
Turn to 275 degrees
Walk 467 steps
Turn to 180 degrees
Walk 86 steps
Turn to 270 degrees
Walk 80 steps
%%
## Flowchart
```d2
vars: {
d2-config: {
dark-theme-id: 200
}
}
classes: {
}
beginning: {shape: oval}
end: {shape: oval}
```