Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

Write a method named, reverse, which reverses the order of an array's elements without creating another array.

The header for the method, reverse, is:

void reverse( int arr() ){

where arr is an array containing any number of integer elements.

For example, if the array is {6, 4, 9, 1, 7) BEFORE calling reverse, then the array should be {7, 1, 9, 4, 6) AFTER calling reverse. Your code should work for any length of integer array containing any values. Your reverse method should not do any keyboard input and no printing to the console.

You should write the method, reverse, in a class named, FinalExam. In the FinalExam class you must also include a main method that tests the method, reverse. The main method may do console output, but does not need any keyboard input. Arrays created in main for use in testing the reverse method should be created using static initialization as in the example below. Here are four tests you should run from the main method by calling the reverse method:

1. Pass an array with 10 elements and then verify the array elements are reversed upon returning from the method, reverse. Here is an example of doing this:
// create the array to test
into myArray = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
int() myArrayRev = { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }; reverse( myArray );
if( Arrays.equals( myArray, myArrRev ) )
System.out.println( "reverse worked for 10 elements." );

NOTE: The Arrays class may be found in the java.util package.

2. Pass an array with 9 elements and then verify the array elements are reversed upon returning from the method, reverse.

3. Pass an array with 1 element and then verify the array element is unchanged upon returning from the method, reverse.

4. Pass an array with 0 elements and then verify the array is unchanged reversed upon returning from the method, reverse.

Attachment:- ArrayCheck.rar

Java, Programming

  • Category:- Java
  • Reference No.:- M92394277
  • Price:- $10

Priced at Now at $10, Verified Solution

Have any Question?


Related Questions in Java

Fundamentals of operating systems and java

Fundamentals of Operating Systems and Java Programming Purpose of the assessment (with ULO Mapping) This assignment assesses the following Unit Learning Outcomes; students should be able to demonstrate their achievements ...

Assessment -java program using array of Assessment -JAVA Program using array of objects

Assessment -JAVA Program using array of objects Objectives This assessment item relates to the course learning outcomes as stated in the Unit Profile. Details For this assignment, you are required to develop a Windowed G ...

Project requirementsfor the problem described in the next

Project requirements For the problem described in the next section, you must do the following: 1. include your student ID at the end of all filenames for all java code files. Three classes have been identified in section ...

Retail price calculatorwrite a java program that asks the

Retail Price Calculator Write a JAVA program that asks the user to enter an item's wholesale cost and its markup percentage. It should then display the item's retail price. For example: (If an item's wholesale cost is 5. ...

Object-oriented software development1 introduction 11

OBJECT-ORIENTED SOFTWARE DEVELOPMENT 1. Introduction 1.1 Assignment Requirement 1.2 Deliverables and Structure (what to submit) 1.3 Software Restrictions 1.4 How to score high... 1.5 Assumptions 2. System Requirements 2. ...

Can someone help me please with those question1what is the

Can someone help me please with those question 1:what is the best data type for student id datatime,currency,number,decimal 2:which relationshipis preferable? one to one,one to many,many to many 3:if you add table A's pr ...

Assignment game prototypeoverviewfor this assessment task

Assignment: Game Prototype Overview For this assessment task you are expected to construct a prototype level/area as a "proof of concept" for the game that you have designed in Assignment 1. The prototype should function ...

Assessment instructionsin this assessment you will complete

Assessment Instructions In this assessment, you will complete the programming of two Java class methods in a console application that registers students for courses in a term of study. The application is written using th ...

Assignment taskwrite a java console application that allows

Assignment task Write a java console application that allows the user to read, validate, store, display, sort and search data such as flight departure city (String), flight number (integer), flight distance (integer), fl ...

Overviewyou are required to use java se 80 and javafx to

Overview You are required to use Java SE 8.0 and JavaFX to develop a Graphical User Interface (GUI) for the FlexiRent rental property management program created in Assignment 1. This assignment is designed to help you: 1 ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As