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

Use the Mandelbrot set (Java) to the code by using the largest number the user p

ID: 3656745 • Letter: U

Question

Use the Mandelbrot set (Java) to the code by using the largest number the user puts in. import java.util.Scanner; import java.io.*; import javax.swing.*; import java.awt.*; public class maxElement extends JApplet { public static int largest_in_array(int[] a, int n) { if (n == 1) return 0; else return Math.max(a[n-1], largest_in_array(a,n-1)); } public static void main(String[] args) { int[] collection = new int[6]; Scanner sc = new Scanner(System.in); System.out.println("Please enter 6 numbers: "); for (int i = 0; i < collection.length; i ++) { collection[i] = sc.nextInt(); } System.out.println(); System.out.println("The largest number in your collection is: "); System.out.println(largest_in_array(collection,6)); } }

Explanation / Answer

Assuming the numbers are integers, and they are stored in an array called myArray. The following has not been tested, but gives the general idea: int max; max = myArray[0]; for (int i = 1; i max) max = myArray[i]; System.out.println(max); } It's working: import java.io.*; import java.lang.*; import java.util.Scanner; import java.util.Arrays; import java.util.logging.Level; import java.util.logging.Logger; public class TestGreatestnNum1 { public static void main(String[] args) { int num; System.out.println("Enter a value to specify no. of inputs" + "(numbers) and find their greatest - 0 to exit: "); InputStreamReader isr = new InputStreamReader(System.in); Scanner scan = new Scanner(isr); try { while((num = scan.nextInt()) != 0) { System.out.println("You have input: "+num); scan.useDelimiter(" "); int[] arr = new int[num]; for(int i = 0; i