Please see the description of the TODOs in the starter file's comments. The following is a sample run (bold fonts repres
Posted: Fri Jul 08, 2022 7:28 am
Please see the description of the TODOs in the starter file'scomments.
The following is a sample run (bold fonts represent userinputs):
Enter the size of the array to be created:5Enter 5 integers: 10 20 30 40 50Array (original): 10 20 30 40 50 Array (after left shift): 20 30 40 50 10
Main.Java New 1 public class Main 2 - { 3 4 - 5 6 8 9 10 11 12 13 14 15 16 17 18 19 20 - 21 22 23 24 25 26 27 28 29 30 31 32 } public static void main(String[] args) { } java.util.Scanner input = new java.util.Scanner(System.in); System.out.println("Enter the size of the array to be created: "); int size = input.nextInt (); //Create an int array (name it myList) that has the size the user just entered. int[] arr = new int[size]; //TODO 1: Write a loop to get user enter values that will be stored in the array System.out.println("Enter " + size + " integers: "); //TODO 2: Print the array * TODO 3: write code below to circular left shift the array arr. * That is, arr[0] will get arr[1]'s value, arr[1] will get arr[2]'s value, * ..., and arr[arr.length-1] will get arr[0]'s value. */ //TODO 4: Print the array again System.out.println("Array (after left shift): ");
The following is a sample run (bold fonts represent userinputs):
Enter the size of the array to be created:5Enter 5 integers: 10 20 30 40 50Array (original): 10 20 30 40 50 Array (after left shift): 20 30 40 50 10
Main.Java New 1 public class Main 2 - { 3 4 - 5 6 8 9 10 11 12 13 14 15 16 17 18 19 20 - 21 22 23 24 25 26 27 28 29 30 31 32 } public static void main(String[] args) { } java.util.Scanner input = new java.util.Scanner(System.in); System.out.println("Enter the size of the array to be created: "); int size = input.nextInt (); //Create an int array (name it myList) that has the size the user just entered. int[] arr = new int[size]; //TODO 1: Write a loop to get user enter values that will be stored in the array System.out.println("Enter " + size + " integers: "); //TODO 2: Print the array * TODO 3: write code below to circular left shift the array arr. * That is, arr[0] will get arr[1]'s value, arr[1] will get arr[2]'s value, * ..., and arr[arr.length-1] will get arr[0]'s value. */ //TODO 4: Print the array again System.out.println("Array (after left shift): ");