2024-08-31 12:08:50 -06:00
# Banana Cake
## Instructions
2024-08-31 12:03:50 -06:00
2024-08-31 12:08:50 -06:00
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.
2024-08-31 12:03:50 -06:00
2024-08-31 14:09:50 -06:00
## Flowchart
2024-08-31 12:08:50 -06:00
```d2
2024-08-31 12:33:50 -06:00
vars: {
d2-config: {
dark-theme-id: 200
2024-08-31 13:39:50 -06:00
layout-engine: elk
2024-08-31 12:33:50 -06:00
}
}
2024-08-31 13:49:50 -06:00
grid-columns: 3
2024-08-31 12:33:50 -06:00
2024-08-31 12:58:50 -06:00
begin: {
shape: oval
2024-08-31 13:39:50 -06:00
# near: top-left
2024-08-31 12:58:50 -06:00
}
2024-08-31 13:39:50 -06:00
2024-08-31 12:18:50 -06:00
begin -> add 3c flour\
2024-08-31 12:23:50 -06:00
-> add 1 1/2 tsp baking soda\
-> add 1/2 tsp cinnamon\
-> add 1/2 tsp salt\
2024-08-31 13:39:50 -06:00
-> stir\
2024-08-31 12:38:50 -06:00
-> add 3 mashed bananas\
-> add 1 tsp lemon juice\
2024-08-31 13:39:50 -06:00
-> stir again\
2024-08-31 12:38:50 -06:00
-> add 3 eggs\
2024-08-31 13:03:52 -06:00
-> add 2tsp vanilla extract\
2024-08-31 13:49:50 -06:00
-> stir a final time\
-> bake @ 350f for 50 min\
-> let cool for 1 hour\
2024-08-31 13:03:52 -06:00
-> end
2024-08-31 13:49:50 -06:00
end: {
shape: oval
# near: bottom-right
}
```
2024-08-31 13:44:50 -06:00
2024-08-31 13:49:50 -06:00
## Pseudocode
2024-08-31 13:54:50 -06:00
```c
/**************************************
* Function Title: BakeBananaCake
*
* Summary: Bake a banana cake
*
2024-08-31 13:59:50 -06:00
* 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.
2024-08-31 14:14:50 -06:00
%%
2024-08-31 14:19:50 -06:00
Assuming a step distance of 2.5 feet.
2024-08-31 14:14:50 -06:00
Sunny path:
2024-08-31 14:19:50 -06:00
Total distance: 1922.59ft
2024-08-31 14:24:50 -06:00
769 steps total
2024-08-31 14:19:50 -06:00
Shady path:
2024-08-31 14:29:50 -06:00
Turn to 270 degrees
Walk 40 steps
Turn to 0 degrees
Walk 120 steps
Turn to 270 degrees
Walk 400 steps
2024-08-31 14:14:50 -06:00
%%
2024-08-31 14:09:50 -06:00
## Flowchart
```d2
classes: {
}
beginning: {shape: oval}
end: {shape: oval}
```