Question: Given the array inputArray (doubles), write a method called swap which will swap any two contiguous (next to each other) elements. Swap will be passed
Given the array inputArray (doubles), write a method called swap which will swap any two contiguous (next to each other) elements. Swap will be passed two parameters, the index of the first element to be swapped and the array name. Write another method printArray that will print the array 5 elements to a line. PrintArray will be passed one parameter the array name. See the videos for help with this.
The array elements are: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10.
hello I am having a problem with this question i barely started and i am already having major trouble! please help. Java btw
this is what I have its already giving me errors.
public class TWC_P04
{
public static void main(String[] args)
{
double[] inputArray = {1,2,3,4,5,6,7,8,9,10};
printArray(inputArray);
swap(3, inputArray);
printArray(inputArray);
}
public static void swap(int k, double [] input)
public static void printArray(double[] input)
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
