Guest User

Untitled

a guest
Jul 22nd, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. /**
  2. * Write a description of class testing here.
  3. *
  4. * @author (Wallace Quach)
  5. * @version (01/25/2010)
  6. * @TA (Arjun)
  7. */
  8. import java.util.Scanner;
  9.  
  10. public class testing
  11. {
  12. public static void main(String[] args){
  13.  
  14. final int RAB_INT = 500; // initial number of rabbits
  15. final int WOLF_INT = 38; // initial number of wolves
  16. final double RAB_G_INCR = 0.12; // Rabbit population growth in isolation
  17. final double WOLF_G_DECR = 0.10; // Wolf population rate of decrease
  18. final double RAB_POP_RA_DECR = 0.0024; // Rate of rabbit decrease due to wolves
  19. final double WOLF_POP_RA_INCR = 0.0002; // rate of increase of wolves due to rabbits
  20.  
  21. int months = 0;
  22. int currentMonth = 0;
  23. int currentWolves;
  24. int currentRabbits;
  25. int newWolves;
  26. int newRabbits;
  27.  
  28.  
  29. System.out.println("Author: Wallace Quach");
  30. System.out.println("Assignment: #1, Wolfs and Rabbits");
  31. System.out.println("TA: Arjun Mukherjee Wednesday, 8:00-8:50 AM");
  32. System.out.println();
  33. System.out.println();
  34. System.out.println("This program models changing population of rabbits and" + "\n" + "wolves, given starting figures.");
  35. System.out.println();
  36. System.out.println();
  37. System.out.print("For how many months would you like to run the simulation? ");
  38.  
  39. Scanner keyboard = new Scanner(System.in);
  40. months = keyboard.nextInt( );
  41. System.out.println();
  42. System.out.println("Month");
  43.  
  44. currentRabbits = RAB_INT;
  45. currentWolves = WOLF_INT;
  46.  
  47.  
  48. while( currentMonth <= months ){
  49. System.out.print(currentMonth);
  50.  
  51. int tempWolves = currentWolves / 13;
  52. int tempRabbits = currentRabbits / 13;
  53.  
  54. while( tempRabbits >= 0 ) {
  55. if( tempWolves == 0 ){
  56. System.out.print("W");
  57. }
  58. if( tempRabbits == 0 ){
  59. System.out.print("R");
  60. }
  61.  
  62. System.out.print(" ");
  63.  
  64. tempRabbits--;
  65. tempWolves--;
  66. }
  67.  
  68. newRabbits = (int) (currentRabbits * (1 + RAB_G_INCR - RAB_POP_RA_DECR * currentWolves));
  69. newWolves = (int) (currentWolves * (1 - WOLF_G_DECR + WOLF_POP_RA_INCR * currentRabbits));
  70.  
  71. currentWolves = newWolves;
  72. currentRabbits = newRabbits;
  73.  
  74. //System.out.println("Rabbits: " + currentRabbits + " ; Wolves: " + currentWolves);
  75. System.out.println();
  76. currentMonth++;
  77. }
  78. System.out.println();
  79. System.out.println("Tasmanian Devil ate " + (currentRabbits + currentWolves) + " total.");
  80. }
  81. }
Add Comment
Please, Sign In to add comment