The diagram shows the most closely related keys for this example. On the top row are the dominant and subdominant keys of E major and D major and below each of these are the related minor keys of B minor, F-sharp minor and C-sharp minor. For more information about modulation (changing key) and the key relationship diagram see Book Chapter 7 which includes a section on Basics of Modulation.
Firstly, we look for cadences at the ends of phrases. We should look mainly for perfect or imperfect cadences but plagal, interrupted, and overlapping cadences are possible. The example is constructed as two 4 bar phrases as suggested by the dotted minim on the dominant note in bar 4. The D-sharp indicates a modulation to the dominant and so I've included a perfect cadence (chord V to chord I) in the dominant key. The example ends on an A indicating a return to the tonic key of A major. Consequently, I've completed a perfect cadence in A major at the end of the piece.Having entered cadences for the obvious ends of phrases, the next stage is to look for places where 'mini cadences' could be included within phrases. At the end of bar 5 into bar 6 we could include a cadence in the key of B minor. This is a closely related key and the cadence fits the melody. Since this cadence is in the middle of a phase, it is more likely to be part of an episode of dynamic harmony than a modulation. (See Book Chapter 7) The three cadences entered are perfect and no imperfect, plagal, interrupted or overlapping cadences are appropriate in this example.