Homework 4

The homework is due on Tuesday, May 30, 2006 at 5pm.
An extension has been given. The homework is now due Friday, June 2, 2006 at 5pm.

Name your files hw02_<problem>.cpp. Email all files to my Helios account.

  1. From the book, Programming Project 7.13, pp 442-443. Conway's "Game of Life". This is a rather lengthy description, so I will not copy it here. If you do not have a text book, there is a copy in the secretary's office that you can borrow to photocopy the assignment. Additional resources: 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.

    ADDITION 5/30: Sample input files follow:

    I've also 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/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.
  2. Modify the menu program to work on an array as follows. The menu will print this to the screen:
      Welcome to the CS221 Homework 4 Menu
      ===============================================
      1.  Enter a list of integers from the keyboard.
      2.  Read a list of integers from a file.
      3.  Multiply all integers in the list.
      4.  Find the minimum integer in the list.
      5.  Find the average and standard deviation of
          the integers in the list.
      6.  Sort the list from smallest to largest.
    
      0.  Exit
      ===============================================
      Enter selection:
    
    Your array should have a maximum size and allow the user or file to enter up to the maximum size of integers (partially filled array). Each selection should be its own function. Selections 1 and 2 get the input for the array. If you use them in succession, the input from the last selection is the one used for selections 3 through 6. Selection 3 finds the product of all numbers in the list and outputs it to the screen. Selection 4 finds the minimum and outputs it to the screen. Selection 5 takes the standard deviation and average function from Lab 6 and modifies it for an array. The output is the average and standard deviation. Selection 6 uses the selection sort algorithm given in the book and outputs all the elements of the array after sorting.