Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import java.util.Arrays; /* * * This program takes an array of integers, reverses the elements and stores them in a new array * */ public

import java.util.Arrays;
/*
*
* This program takes an array of integers, reverses the elements and stores them in a new array
*
*/
public class ReverseElements
{
/**
Reverses an array.
@param data - the input array
@return an array with the elements of data in reverse order
*/
public static int[] reverse(int[] data)
{
  //-----------Start below here. To do: approximate lines of code = 6
  //
 
 
 
 
 
 
 
 
  //-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions.
}


public static void main(String[] args)
{
int[] data = { 1, 4, 9, 16, 9, 7, 4, 9, 11 };
int[] reversed = reverse(data);
for (int i = 0; i < reversed.length; i++)
{
System.out.print(reversed[i] + " ");
}
System.out.println();
System.out.println("Expected:11 9 4 7 9 16 9 4 1");
}
}


P.S: Please write the code as well as include screenshots for reference along with output

Step by Step Solution

3.40 Rating (153 Votes )

There are 3 Steps involved in it

Step: 1

import javautilArrays This program takes an array of integers reverses the e... 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

Data Structures and Algorithms in Java

Authors: Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser

6th edition

1118771334, 1118771338, 978-1118771334

More Books

Students also viewed these Programming questions