public static int findEscapeCount(double x,
double y,
int maxIterations)
Determines how many iterations of the following operation are required until the condition (a * a + b * b) > 4 is reached:
tempA = a * a - b * b + x tempB = 2 * a * b + y a = tempA b = tempB
where a and b are initially zero, and x and y are given parameters. For example, with x = 1 and y = 0.5, after one iteration a should be 1 and b should be 0.5. After two iterations a should be 1.75 and b should be 1.5, at which point the method returns with value 2 since (1.75)2 + (1.5)2 = 5.3, which is greater than 4. If the condition (a * a + b * b) > 4 is not reached within maxIterations, the method just returns maxIterations.
Parameters:
x - given x value
y - given y value
maxIterations - maximum number of iterations to attempt
Returns:
number of iterations required to get (a * a + b * b) > 4, or maxIterations
Please find the code below:
FindMaxInteration.java
package classes10;
import java.util.Scanner;
public class FindMaxInteration {
private static double a=0;
private static double b=0;
public static int findEscapeCount(double x,double
y,int maxIterations){
int iteration = 0;
while(!((a * a + b * b) >
4)){
iteration++;
double tempA = a
* a - b * b + x;
double tempB = 2
* a * b + y;
a = tempA;
b = tempB;
if(iteration>maxIterations){
return maxIterations;
}
}
return iteration;
}
public static void main(String[] args) {
Scanner sc = new
Scanner(System.in);
double x,y;
int maxIteration;
System.out.print("Enter value of x
: ");
x = sc.nextDouble();
System.out.print("Enter value of y
: ");
y = sc.nextDouble();
System.out.print("Enter value of
max iteration : ");
maxIteration = sc.nextInt();
System.out.println("Escape count is
"+findEscapeCount(x, y, maxIteration));
}
}
output:

public static int findEscapeCount(double x, double y, int maxIterations) Determines how many iterations of the following...