ok after a long time i am repying u,
this comes automatically, practice the scales.and after that u'll be able to figure them out.
just pick a note and try the other note here and there, and move on soon u'll make the whole song, if u don't like the scale shift to another scale.
ta da , presto,
u wrote a song