Airline ticket

Airline ticket

Abbreviating airport names.

When boarding passes are created for passengers, the departure and arrival airport names are written in an abbreviated form to ensure they fit within the designated area on the ticket.

Make


Write a program that allows the user to enter the names of two airports. The program should output the first four characters of each airport separated with a hypen symbol: "-".

Use this boilerplate code as a starting point:

Success Criteria

Remember to add a comment before a subprogram, selection or iteration statement to explain its purpose.

Complete the subprogram called `airports` that:

  1. Takes the two parameters, `departure` and `arrival` and returns the first four characters of each airport in upper case separated with a hyphen.

The main program:

As this is a function within a bigger system, the airport names are not input by the user. For testing purposes they are hard-coded into the function call instead. There is nothing for you to do here.

Typical inputs and outputs from the program would be:

If the departure airport is London and the destination is Madrid, the output would be: LOND-MADR


If the departure airport is Palma and the destination is Manchester, the output would be: PALM-MANC

Knowledge Organiser

Use these resources as a reference to help you meet the success criteria.

Programming guide:

Evaluate


Run the unit tests below to check that your program has met the success criteria.

Dallas to Heathrow

DALL-HEAT

Heathrow to Hartsfield

HEAT-HART

John F Kennedy to Gatwick

JOHN-GATW

Check that you have:

  • Used comments within the code to describe the purpose of subprograms, conditions and iterations.
  • Used meaningful identifier names. That means the names of subprograms and variables indicate what they are for.