Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Instructions: Write a complete Java program that meets the following requirements: Main Method: Initialize a 2 D ArrayList of integers with the following values: {

Instructions:
Write a complete Java program that meets the following requirements:
Main Method:
Initialize a 2D ArrayList of integers with the following values:
{{1,1,3,1,5},{1,1,3,1,5},{1,1,3,1,5},{1,1,3,1,5},{1,1,3,1,5}}
Name this 2D ArrayList Data1.
Initialize a 2D ArrayList of integers with the following values:
{{1,2,3,4,5,6,7,8,9,10},{-2,-1,2,1},{},{2,2,2}}
Name this 2D ArrayList Data2.
Run a method named SearchEven. Pass Data1 as an argument to the SearchEven method. SearchEven will return a 1D ArrayList. This ArrayList will contain the rows and columns of where each even number in the 2D parameter is located. If the 2D ArrayList contains no even numbers, the ArrayList returned will only contain the value -1.
Use a separate method to display the contents of the ArrayList that SearchEven returns. If Data1 contained at least 1 even number, then output one row and 1 column per line. If Data1 did not contain any even numbers, then display a message that indicates this. Name this method: Display_Locations.
Run the method SearchEven again. Pass Data2 as an argument to the SearchEven method.
Use the Display_Locations method to display the contents of the ArrayList that SearchEven returns. If Data2 did not contain any even numbers, then display a message that indicates this.
Sample RunNotes:
This program needs to work with 2D ArrayLists of integers of any size.
The 2D ArrayLists can have any (non-negative) number of rows.
Each row can have any (non-negative) number of elements.
Making an algorithm before attempting to code this program will be helpful to you.
image text in transcribed

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

Databases And Information Systems 1 International Baltic Conference Dbandis 2020 Tallinn Estonia June 19 2020 Proceedings

Authors: Tarmo Robal ,Hele-Mai Haav ,Jaan Penjam ,Raimundas Matulevicius

1st Edition

303057671X, 978-3030576714

More Books

Students also viewed these Databases questions

Question

suggest a range of work sample exercises and design them

Answered: 1 week ago