Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Program must be in Java lanugage: In a predator-prey simulation, you compute the

ID: 3872810 • Letter: P

Question

Program must be in Java lanugage: In a predator-prey simulation, you compute the populations of predators and prey, using the following equations:

Here, A is the rate at which prey birth exceeds natural death, B is the rate of predation, C is the rate at which predator deaths exceed births without food, and D represents predator increase in the presence of food. Write a program that prompts users for these rates, the initial population sizes, and the number of periods. Then print the populations for the given number of periods. As inputs, try A = 0.1, B = C = 0.01, and D = 0.00002 with initial prey and predator populations of 1,000 and 20.

Please Answerin Java

4. In a predator-prey simulation, you compute the populations of predators and prey, using the following equations: preyn+1 = prey,, x (1 + A-B × predn ) predn+1 = pred, x (1-C + D × prey.) Here, A is the rate at which prey birth exceeds natural death, B is the rate of predation, C is the rate at which predator deaths exceed births without food, and D represents predator increase in the presence of food. Write a program that prompts users for these rates, the initial population sizes, and the number of periods. Then print the populations for the given number of periods. As inputs, try A = 0.1, B = C = 0.01, and D = 0.00002 with initial prey and predator populations of 1,000 and 20

Explanation / Answer

//'main' method must be in a class 'Rextester'.
//Compiler version 1.8.0_111

import java.util.*;
import java.lang.*;
import java.io.*;
import java.util.Scanner;


class Main
{  
public static void main(String args[])
{
  
System.out.println("Enter no of period");
Scanner ss1 = new Scanner(System.in);
int n = ss1.nextInt();  

System.out.println("Enter the rate at which prey birth exceeds natural death");
Scanner s = new Scanner(System.in);
float a = s.nextFloat();
  
System.out.println("Enter the rate of predation");
Scanner ss = new Scanner(System.in);
float b = ss.nextFloat();
  
System.out.println("Enter the rate at which predator deaths exceed births without food");
Scanner sss = new Scanner(System.in);
float c = sss.nextFloat();
  
  
System.out.println("Enter the rate of predator increase in the presence of food");
Scanner ssa = new Scanner(System.in);
float d = ssa.nextFloat();
  
System.out.println("Enter the initial population sizes of predator");
Scanner s2 = new Scanner(System.in);
float pred = s2.nextFloat();
  
  
System.out.println("Enter the initial population sizes of prey");
Scanner s3 = new Scanner(System.in);
float prey = s3.nextFloat();
  
for(int i=0; i< n ; i++){
prey = prey* (1+a-b*pred);
pred = pred* (1-c+d*prey);
}
  
  
System.out.println("predator after " + n + " period = " + pred);
System.out.println("prey after " + n + " period = " + prey);
  
  
  
}
  
  
}

Dr Jack
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote