Program 4 for CS367