Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Create a new Java Project and give it an appropriate name. The name should contain the lab assignment number and topic. 2. This assignment

1. Create a new Java Project and give it an appropriate name. The name should contain the lab assignment number and topic.

2. This assignment will have two classes:

a. The first class (ArrayTests) will be contain the main method for testing your program.

b. The second class (ArrayOps) will be a template for testing array operations.

3. Copy and paste the starter code for the main method into the test class:

public static void main( String [] args )

{ int [] input = { 1, 9, -2, 8, -4, 7, -5, 3, 6, 0 }; ArrayOps testObj = // Instantiate the testObj using

// the constructor.

// 1. Reference the toString-method here to display the array.

// Display in the IDE console window. Test and confirm the /

/ toString method works before proceeding. .

// 2. Display the index for the smallest value in the array

// in the IDE console window;

String output = "Index for the smallest value is: " + testObj.findMin() + " " ;

// 3. Reference the reverse-method to change the array order.

// 4. Reference the toString-method to display the reversed

// array in the IDE console window.

// 5. Reference the findMin-method to return the index of

// the smallest value stored in the reversed array. Display

// in the IDE console window. }

4. The array operations class must have these members: a. One instance field named data of type integer array. b. One constructor called ArrayOps with one argument: an array. The constructor must make a deep copy of the input array. c. Three instance methods: toString, reverse and findMin.

5. Create a private instance field named data of type int-array in your class.

6. Write the constructor ArrayOps with one argument. Use the input argument to create a deep copy of the input array. The variable name data is the reference to the deep copy. Be sure to write and test this constructor before proceeding to the next step.

7. Write a method called toString. This method has no formal parameter inputs and returns a String. Use the Arrays.toString()method to build the output string. The method should return the output string. Be sure to write and TEST this method before proceeding to the next step.

8. Write an instance method called reverse that returns nothing. The method should have no formal parameters. The method should do an in-place reversal of the elements stored in the data array. Do not use any additional arrays to reverse the order. See the Swap example on how to swap values.

9. Write an instance method called findMin that returns type int. The method has no formal parameters. The method should locate and return the index of the smallest value stored in the data array

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

Genomes And Databases On The Internet A Practical Guide To Functions And Applications

Authors: Paul Rangel

1st Edition

189848631X, 978-1898486312

More Books

Students also viewed these Databases questions

Question

What is cultural tourism and why is it growing?

Answered: 1 week ago

Question

understand the key issues concerning international assignments

Answered: 1 week ago