Programming Assignment 7

Imagine a file F containing information records about students, boys and girls. Each record stores name, age and gender. The file has an arbitrary number m+n of records and an arbitrary sequence of m boys and n girls. You are supposed to write a program that uses stacks (may be several but a constant number with respect to m and n), and additional constant number of character and integer variables to create two stacks SG and SB, one of girls and one of boys, from F. In other words, you are essentially separating the boys and girls using only stacks. Furthermore, you are supposed to finally write the names back into two files, one file G for girls and one file B for boys so that the sequences of names of boys (respectively, girls) in the two separate files are the same as they were in the mixed file read earlier.

So, if the input file had b1 g1 b2 b3 g2 g3 b4 then the two files in the output will be b1 b2 b3 b4 and g1 g2 g3.