Just write a melody any way you want to. Melodies usually move by step meaning that they either ascend or descend by a 2nd interval. If a couple of notes are more than a 3rd interval way from each other it is called a leap. You can put leaps in the melody but people don't typically put more than a leap of a 6th interval because they can be hard to sing. If you are composing for an instrument its not such a big deal. Under the melody, remember that the first and third beats are strong and two and four are weak, you want to put 3rds under strong beats and 6ths under weak beats. You can also put 5ths or octaves on weak beats but they shouldn't be on successive weak beats because it is stylistically incorrect. I would suggest that you just read music theory books by Hindemith and Schoenberg and also on amazon you can buy music theory books by Stan Funicelli that are really cheap and incredibly useful and instructive.