“Wind was less than 12 knots so Mary could safely land in Courtenay, but the wind conditions delayed their leave time and has slowed down their travel so that their overall travel time is longer than expected. Mary will not make her booked landing time. Write an algorithm that will determine if there is a later landing time available in the Courtenay airfield. If not, she will have to default to Smits Field”.
- Input how long the trip will take – store it in a variable called ātripLengthā
- Input when Mary and Louise took off – store it in a variable called āleaveTimeā.
- Calculate arrival time by adding ātripLengthā + āleaveTimeā.
- Input the landing times in Courtenay, store it in a variable called ālandTimesā.
- Compare āarrivalTimeā to each number sequence in ālandTimesā.
- If āarrivalTimeā is greater than ālandTimesā – move to the next available ālandTimesā.
- If āarrivalTimeā is less than or equal to ālandTimesā, Mary can land in Courtenay as output “landDestination: Courtenay”.
- If āarrivalTime” remains greater than “landTimes”, Mary must default to “landDestination: Smit Airfield”.
mwilson
The inputs for this one would be ‘current time’ and ‘remaining trip time’ – because the calculations are being done while in the air (so leave time isn’t relevant).
Otherwise, this works.