Answer:
you would have to first identify the tonality, then use tonic, subdominant, and dominant chords in that particular tonality (I, IV, V)
Match the chord tones with the melody
Explanation:
example in the key of "C"
I would be the C chord would sound best with melody notes which include the C chord (C, E, G)
IV would be F chord (F, A, C)
V would be G chord (G,B,D)
I, IV, and V are different based on the tonality
The I is the tonic chord and matches the key of the piece.