Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Fred R. McFadden, Jeffrey Slater, Mary B. Prescott

5th Edition

0805360549, 978-0805360547

More Books

Students also viewed these Databases questions

Question

2. What potential barriers would you encourage Samuel to avoid?

Answered: 1 week ago