Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Write a description of class testing here.
- *
- * @author (Wallace Quach)
- * @version (01/25/2010)
- * @TA (Arjun)
- */
- import java.util.Scanner;
- public class testing
- {
- public static void main(String[] args){
- final int RAB_INT = 500; // initial number of rabbits
- final int WOLF_INT = 38; // initial number of wolves
- final double RAB_G_INCR = 0.12; // Rabbit population growth in isolation
- final double WOLF_G_DECR = 0.10; // Wolf population rate of decrease
- final double RAB_POP_RA_DECR = 0.0024; // Rate of rabbit decrease due to wolves
- final double WOLF_POP_RA_INCR = 0.0002; // rate of increase of wolves due to rabbits
- int months = 0;
- int currentMonth = 0;
- int currentWolves;
- int currentRabbits;
- int newWolves;
- int newRabbits;
- System.out.println("Author: Wallace Quach");
- System.out.println("Assignment: #1, Wolfs and Rabbits");
- System.out.println("TA: Arjun Mukherjee Wednesday, 8:00-8:50 AM");
- System.out.println();
- System.out.println();
- System.out.println("This program models changing population of rabbits and" + "\n" + "wolves, given starting figures.");
- System.out.println();
- System.out.println();
- System.out.print("For how many months would you like to run the simulation? ");
- Scanner keyboard = new Scanner(System.in);
- months = keyboard.nextInt( );
- System.out.println();
- System.out.println("Month");
- currentRabbits = RAB_INT;
- currentWolves = WOLF_INT;
- while( currentMonth <= months ){
- System.out.print(currentMonth);
- int tempWolves = currentWolves / 13;
- int tempRabbits = currentRabbits / 13;
- while( tempRabbits >= 0 ) {
- if( tempWolves == 0 ){
- System.out.print("W");
- }
- if( tempRabbits == 0 ){
- System.out.print("R");
- }
- System.out.print(" ");
- tempRabbits--;
- tempWolves--;
- }
- newRabbits = (int) (currentRabbits * (1 + RAB_G_INCR - RAB_POP_RA_DECR * currentWolves));
- newWolves = (int) (currentWolves * (1 - WOLF_G_DECR + WOLF_POP_RA_INCR * currentRabbits));
- currentWolves = newWolves;
- currentRabbits = newRabbits;
- //System.out.println("Rabbits: " + currentRabbits + " ; Wolves: " + currentWolves);
- System.out.println();
- currentMonth++;
- }
- System.out.println();
- System.out.println("Tasmanian Devil ate " + (currentRabbits + currentWolves) + " total.");
- }
- }
Add Comment
Please, Sign In to add comment