I am marking down the scale degrees for this exercise. I think the tonic in this piece is D as it feels like a resolution. To find the first scale degree in the exercise I counted up from D until I got to A, which was five steps. So This is the fifth scale degree, which is correct. Then I did the same for the other degree and got to two (as E is right above D). The answer, however, is apparently 7. Where did I go wrong? Does this mean that the tonic is actually F? Because that doesn't sound right to me.
With 2 sharps and an anacrucis of A, yes, it's in D major. That A is 5th, and the E note will be 2 (or possibly 9), there's no way it could be 7. Had the dot been on the space below, making it C♯, then, yes, it would be 7.
With the F♯ in the key sig. the tonic would never be F anyway.