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

Can you please help me with this JAVA code?? Many times when computer scientists

ID: 3600355 • Letter: C

Question

Can you please help me with this JAVA code?? Many times when computer scientists write a program, they do not develop the entire thing themselves. Instead, they may use methods that have been written by others. In this lab, your task is to write a program that performs operations all arrays. However, you should NOT write the code to do this yourself. Instead, you should write a driver program that calls methods from the java.util.Arrays class. In particular, you will be using these methods: public static void sort (int[] a) -sorts the specified array into ascending numerical order sorts the specified public static void sort(int a, int fromIndex, int toIndex) range of the array into ascending order public static String tostring(intl a) -returns a string representation of the contents of the specified array More documentation on these methods can be found at https://docs.oracle.com/javase/8/docs/api/java/util/Arrays.html Your program should begin by prompting the user for ten integers, reading them in, and storing them in an integer array. Next, prompt the user for a from and to index and sort the array between those two indexes. Call the toString method to convert the array to a string and display that string to the user using System.out.printin. Finally, sort the entire array, use the toString method to convert it to a string, and display it to the user. An example is shown below. Enter 10 integers: 7 9 4 2 15 8 10 3 6 Enter an index to start sorting from: 3 Enter an index to stop sorting at: 6 [7, 9, 4, 1, 2, 5, 8, 10, 3, 6] [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

Explanation / Answer

Please comment if you want any modification..

import java.util.Arrays;

import java.util.Scanner;

public class SortDriver {

public static void main(String[] args) {

int i=0, from, to;

int[] arr = new int[10];

Scanner sc = new Scanner(System.in);

System.out.print("Enter 10 integers: ");

while(i!=10){

arr[i] = sc.nextInt();

i++;

}

System.out.print("Enter an index to start sorting from: ");

from = sc.nextInt();

System.out.print("Enter an index to stop sorting at: ");

to = sc.nextInt();

Arrays.sort(arr, from, to);

System.out.println(Arrays.toString(arr));

Arrays.sort(arr);

System.out.println(Arrays.toString(arr));

}

}