0203

“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”.

← Previous Post

Next Post →

1 Comment

  1. 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.

Leave a Reply

Your email address will not be published. Required fields are marked *