CS 2401 Assignment #2

Due Date: Sunday, September 13, 2009.

Objective: The goal of this assignment is to practice using 2-dimensional arrays.

Background: To study human behavior, researchers use simple economic games like the following Trust Game played between two players: an Investor and a Trustee. In the experiment, several pairs play, and each game between two players continues for several rounds. In every round:

For example, if the investor invested $15, then the trustee gets $45 and returns $22 to the investor. The trustee has an incentive to return some money to the investor -- otherwise, the investor will not invest anything in the next round, and the trustee will have no profit. This game is used because it captures a lot of notions about trust.

Assignment: Write a program that, first, stores the game results (which are originally given in a file, one game per line) in two two-dimensional arrays:

Your program should include the following methods:

As an example, let us assume that we have two pairs playing the game, with each game consisting of two rounds. In the first game:

In the second game: The corresponding file has the form
 10 15 14 11 
 5 12 20 7
The investor array has the form
 10 14
 5  20
and the trustees array has the form
 15 11
 12  7
In this case:

For extra credit: Redo Programming Assignment 1 using a two-dimensional array instead of two one-dimensional arrays.