Does the number of base pairs between the end of one gene and the start of the next gene have to be a multiple of 3?
There absolutely is not a rule saying that all genes on a strand should be in the same frame.

Your program is looking for ORFs (open reading frames) and it should identify all of them, in every frame.  If you were being very thorough, you should generate the reverse complement of your sequence, and search that for ORFs too.  But I guess if you were given this sequence, presuambly the professor gave you the sequence in the desired orientation.