bourne shell programming help!

Our rules state: "(6) Do not post classroom or homework problems." And I have to say that this looks like homework to me.