lab 6 for CSCI160. See http://csci.viu.ca/~wesselsd/courses/csci160/labs/lab6.html