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 right shift): 20 30 40 50 10
Main.Java New 1 public class Main 2 - { 3 4- 5 6 7 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 33 34 } 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 System.out.println("Array (original): "); * TODO 3: write code below to circular right shift the array arr. * That is, arr[arr.length-1] will get arr[arr.length-2]'s value, * arr[arr.length-2] will get arr[arr.length-3]'s value, * arr[2] will get arr[1]'s value, * arr[1] will get arr[0]'s value, and * arr[0] will get arr[arr.length-1]'s value. //TODO 4: Print the array again System.out.println("Array (after right shift): "); ر...
Please see the description of the TODOs in the starter file's comments. The following is a sample run (bold fonts repres
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am