merging two similar java programs into one and creating a junit test

take a section of one program and replace it with a similar section of the other. Write a unit test to be certain the program performed after the change. explain process of identifying changes, changes needed to make app work, and process of writing unit test.