Homework 6 - Extra Credit Assignment

Due: Friday, November 21, 2008 at 5:00pm
Since this is an extra credit assignment, no late assignments will be accepted. If you do not do this assignment, it will not hurt your grade.

  1. (10 points) Convert Homework 5 to use a structure for each employee and an array of the structure to store all the employees. The structure should contain at least the employee's name, the employee's pay rate and the hours the employee worked that week. You may add additional data items to the structure if you wish.

    Use the same menu as Homework 5. Also, the same four functions that are required for Homework 5 should exist in this program. Your only change to those functions will be to pass the structure array to the functions and alter the structure array within the functions instead of using parallel arrays as in Homework 5.

  2. (10 points) Implement Conway's "Game of Life". See the following resources for the rules of the game: You will need to use a multidimensional character array to store the screen output (i.e. each cell in the table will be one "dot" on the screen). If there is an organism in the cell, use an asterick ('*') character to indicate that. If there is not, use a space character. Your array should contain 80 columns and 22 rows, as that is the size of the terminal when you open it in the labs.

    Use a text file to contain the initial generation for the game. The text file has the same format as the screen output. That is, it will contain 22 lines with each line having 80 characters. A space indicates an empty cell and an asterick indicates an occupied cell. Try using some of the initial configurations given in the above resources.

    Sample input files follow:

    You will need to prompt the user for the number of generations and loop that many times. In each iteration of the loop, apply the game rules as given in the above resources. To implement the rules correctly, you will need a second multidimensional character array that contains the "new" state of the cells (after all the rules have been applied). You cannot change the "current" cells because it will incorrectly affect the cells that come after it. After applying all rules, copy the "new" state array into the "current" state array and print the array to the screen.

    I've uploaded a working binary solution to the problem so you can see how the game appears on these sample files. From within Helios, run the following command:

    /usr/users/mdanfor/public_html/cs221-f08/gol
    It will prompt you for the number of generations (I'd suggest start low like 50 and only go higher for more complex patterns) and the filename. Try it out on the above filenames to see it in action. It works best if your terminal is set for 24 rows and 80 cols. It uses some more advanced programming to make the game appear like a movie. You do not need to do that in order to get credit for the assignment.