// Arup Guha
// 9/15/09
// Honors Mathematical Modeling
// Simulation of dem/rep/ind problem from 1.4 of the textbook.

#include <stdio.h>

#define DEMS_INIT 50000
#define REP_INIT 100000
#define IND_INIT 250000
#define NUMSTEPS 100

int main() {
    
    double dem = DEMS_INIT;
    double rep = REP_INIT;
    double ind = IND_INIT;
    int i;
    
    // Step through each day.
    for (i=0; i<NUMSTEPS; i++) {
        
        // Print out this day.
        printf("Day %d: Dem %.0lf\tRep %.0lf\tInd %.0lf\n", i, dem, rep, ind);
        
        // Calculate for the next day.
        double new_dem = .6*dem + .2*ind + .05*rep;
        double new_rep = .75*rep + .4*ind + .2*dem;
        double new_ind = .2*rep + .2*dem + .4*ind;
        
        // Reset our variables for the next day.
        dem = new_dem;
        rep = new_rep;
        ind = new_ind;
        
    }    

    system("PAUSE");
    return 0;
}
