Adventures in SuperComputing - Summer Teacher Institute

Example Site

Computational Model

There are many ways to implement a model for population growth interactions on a computer; e.g., Java, C++, or Excel. A "for loop" or similar construct will be useful.

Sample Java Program

import gov.lanl.java.UserInput;
// birth rate of 'roos = 1/2
// death rate of 'roos = 1/18
// initial population of 'roos = 50

public class Roo {

public static void main(String args[]) {

double birthRate = 1.0/2; // Why "1.0"? Why not just "1"?
double deathRate = 1.0/3;
int initialRoos = 50;
int oldRoos, newRoos;

System.out.println("0 " + initialRoos);

oldRoos = initialRoos;

for(int i = 1; i <= 10; i++) {

newRoos = (int) (oldRoos + birthRate*oldRoos - deathRate*oldRoos);
// What does the "(int)" do above? Why do we do it?
System.out.println(i + " " + newRoos);
oldRoos = newRoos;

}

}

}