Question: In Java Please In this exercise you will be manipulating data in a one dimensional array. All the work for this step will be done
In Java Please
In this exercise you will be manipulating data in a one dimensional array. All the work for this step will be done in public static void main(String[ ] args ).
This is how to declare an array of primitives: int [ ] myNums = new int[10]; //this creates an array of 10 ints and //all the values are initialized to zero.
Create a class named ArrayWork. In this class create the public static void main(String[ ] args ) method.
Create and initialize an array of ten ints. Change the values from zero to other values. (you can use random numbers using the Random class or type in values)
a) Print the contents of the array.
b) Print the contents of the array in reverse order.
c) Print every other element of the array. d) Remove the 5th element of the array, moving all the other elements after the 5th element down one slot. Assign a value of 0 to the last slot in the array. Print the contents of the array once you have done this:
example: original contents: 3 5 6 2 7 8 1 13 12 15
remove 7: new contents: 3 5 6 2 8 1 13 12 15 0
e) Remove the 3rd element of the array, shifting all the elements after the 3rd element down one slot. Fill in the last slot with a 0. Print the contents of the array once you have done this.
example: original contents: 3 5 6 2 8 1 13 12 15 0
remove 6: new contents: 3 5 2 8 1 13 12 15 0 0
f) Create a new array, twice the size of the original array. Copy the contents of your original array into this new expanded array. Print the new array to verify. ________________________________________________
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
