“While Mary is figuring out which airfield to land in, Louise needs to book a reservation at the Atlas Cafe. She was given a list of open times for the reservation. Based on the place they land, she needs to add 20 minutes (Courtenay) or 45 minutes (Smits Field) to their landing time to determine the reservation time. She also needs to book either a taxi (Courtenay) or the airfield loaner car (Smits Field). Write an algorithm that will take the necessary outputs from Problem 3 and determine which reservation time and mode of transportation she needs to book.”
- Input how long the trip will take – store it in a variable called “tripLength”.
- Input when Mary and Louise left – store it in a variable called “leaveTime”.
- Calculate the arrival time by adding “tripLength” + “leaveTime”. Store in a variable called “arrivalTime”.
- Input the available landing times – store it in a variable called “landingTime”.
- Run “arrivalTime” against each possible number in “landingTimes”.
- If “arrivalTime” is greater than “landTimes” move to the next “landTime”.
- If “arrivalTime” is less than or equal to “landTimes”, they can land in Courtenay – store this as “Courtenay” in a variable called “landDestination”.
- If every “landTimes” is later than “arrivalTime”, They must default to Smit Field – store this as “Smit Airfield” in a variable called “landDestination”.
- Input available reservation times at the Atlas Cafe as variable “openRes”.
- If “Destination=Courtenay?” is false – calculate “arrivalTime + 45mins”. Store this variable as “atlasRes”.
- If “Destination=Courtenay?” is true – calculate “arrivalTime + 20mins”. Store this variable as “atlasRes”.
- Run “atlasRes” against “openRes”.
- If “atlasRes” is greater than (unavailable) “openRes”, compare to the next “openRes”.
- If “atlasRes” is lesser than or equal to (available) “openRes” – store in variable as “resTime”
- Output: Book “resTime”
- If all “openRes” is false – store in variable as “atlasRes” and output to “stop”
- If output is book “resTime” as “Courtenay=false” then book shuttle car.
- If output is book “resTime” as “Courtenay=true” then book taxi.
mwilson
This could be more efficient, but you’ve got the gist of it.
Here’s my version: https://docs.google.com/document/d/1Mv4ZhDj3SjXL3M5hE1gY2XjY9Kb_1EUrU0-dg3abN14/edit?usp=sharing
jp92
Oh man – seeing your examples is extremely helpful in me understanding this better. 0204 is where my brain started to derail. I had done this FC probably 7 or 8 times trying to find a more logical algorithm routing. If we do anymore of these charts I feel like I will be able to do my operations much cleaner.