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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started