Question: P 2 - ArrayEditor [ 1 0 points ] The attached ArrayEditor program initializes the TenNumbers array with ten random integers. Begin by importing the

P2- ArrayEditor [10 points]
The attached ArrayEditor program initializes the TenNumbers array with ten random integers. Begin by importing
the ArrayEditor project to NetBeans. Next, modify the methods in this program so that the program prints four lines
of output, containing:
All elements in the TenNumbers array.
The contents of TenNumbers, after swapping the first and last elements in the array
The contents of T enNumbers, after replacing all even elements with 0.
The largest value in TenNumbers.
The provided seed code has four method declarations:
The getAllElements method receives an input array of integers and returns a String with all the values in
the array.
The swapFirstLast method receives an input array of integers and returns a new array of integers with the
same values as the input array, except the first and last elements being swapped.
The replaceEvensWithZeros method receives an input array of integers and returns a new array of
integers with the same values as the input array, except that all even elements are replaced with 0.
The largestElement method receives an input array of integers and returns the largest value in this array
You will need to use looping statements and method calls.
A screenshot of the execution of your program should look like this:
This in Java using netbeains also pleaze build of the code added
package arrayeditor;
public class ArrayEditor {
static String getAllElements(int[] input){
String output ="";
// Complete this method
return output;
}
static int[] swapFirstLast(int[] input){
int[] output = new int[input.length];
// Complete this method
return output;
}
static int[] replaceEvensWithZeros(int[] input){
int[] output = new int[input.length];
// Complete this method
return output;
}
static int largestElement(int[] input){
int largest = Integer.MIN_VALUE;
// Complete this method
return largest;
}
public static void main(String[] args){
int[] TenNumbers = new int[10];
for (int index =0; index TenNumbers.length; index++){
TenNumbers[index]=(int)(Math.random()*100);
}
System.out.println("All elements: "+ getAllElements(TenNumbers));
System.out.println("After swapping the first and last elements in the array: "+ getAllElements(swapFirstLast(TenNumbers)));
System.out.println("After replacing all even elements with 0: "+ getAllElements(replaceEvensWithZeros(TenNumbers)));
System.out.println("The largest value: "+ largestElement(TenNumbers));
 P2- ArrayEditor [10 points] The attached ArrayEditor program initializes the TenNumbers

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!