1) Write method, extractEvens, which accepts an array of int and returns an array containing only the even integers found in the formal parameter. The returned array should be the right- size, meaning that all of its elements are used to store an even int found in the parameter. This means that the returned array may have anywhere from zero to n elements, where n is the length of the formal parameter array.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Need help with a java program.

Firefox
File
Edit
View
History
Bookmarks
Tools
Window
Help
Sun Dec 5 1:29 PM
Welcome Students | Maricopa C X
Lab17
New Tab
X +
1
NEW
o 8 https://learn.maricopa.edu/courses/1196290/assignments/11671791
Lab17.pdf
110A
I, Download
O Info
X Close
ZOOM
+
1) Write method, extractEvens, which accepts an array of int and returns an array containing
only the even integers found in the formal parameter. The returned array should be the right-
size, meaning that all of its elements are used to store an even int found in the parameter. This
means that the returned array may have anywhere from zero to n elements, where n is the
length of the formal parameter array.
2) Write method, compress, which accepts an array of int and returns an array containing the
sums of each pair of integers in the array parameter. So, if arr is the array parameter, then the
first element of the returned array contains the sum arr[0] and arr[1], the second element of
the returned array contains the sum of arr[2] and arr[3], etc. If the array parameter has an odd
number of elements, then the last element of the returned array contains the last element of
the array parameter.
3) Write method, union, which accepts two arrays of int as sets. This means that neither array
contains duplicates within them. This method returns an array that is the union of the two
parameter sets (arrays). The union is also a set and therefore cannot contain duplicates. This
method must make sure that if the two parameter sets have a common element value, then
that value should appear in the union set (array) only once. The union array returned should be
right-sized.
4) Write method, shuffle, which accepts an array of int, creates a copy of the formal parameter,
shuffles the copy, then returns the copied, shuffled array, leaving the formal parameter
unchanged. Shuffling is a process of swapping each element of array with another element
randomly chosen from the array.
5 BONUS Pts: For testing the shuffle method have main call shuffle, repeatedly having it
shuffle its previously returned array until the returned (shuffled) array is identical (equal) to
the original array that was first shuffled. So, your loop would contain a statement like the
following:
shuffledArray
shuffle( shuffledArray );
1,903
DEC
étv
LO
Transcribed Image Text:Firefox File Edit View History Bookmarks Tools Window Help Sun Dec 5 1:29 PM Welcome Students | Maricopa C X Lab17 New Tab X + 1 NEW o 8 https://learn.maricopa.edu/courses/1196290/assignments/11671791 Lab17.pdf 110A I, Download O Info X Close ZOOM + 1) Write method, extractEvens, which accepts an array of int and returns an array containing only the even integers found in the formal parameter. The returned array should be the right- size, meaning that all of its elements are used to store an even int found in the parameter. This means that the returned array may have anywhere from zero to n elements, where n is the length of the formal parameter array. 2) Write method, compress, which accepts an array of int and returns an array containing the sums of each pair of integers in the array parameter. So, if arr is the array parameter, then the first element of the returned array contains the sum arr[0] and arr[1], the second element of the returned array contains the sum of arr[2] and arr[3], etc. If the array parameter has an odd number of elements, then the last element of the returned array contains the last element of the array parameter. 3) Write method, union, which accepts two arrays of int as sets. This means that neither array contains duplicates within them. This method returns an array that is the union of the two parameter sets (arrays). The union is also a set and therefore cannot contain duplicates. This method must make sure that if the two parameter sets have a common element value, then that value should appear in the union set (array) only once. The union array returned should be right-sized. 4) Write method, shuffle, which accepts an array of int, creates a copy of the formal parameter, shuffles the copy, then returns the copied, shuffled array, leaving the formal parameter unchanged. Shuffling is a process of swapping each element of array with another element randomly chosen from the array. 5 BONUS Pts: For testing the shuffle method have main call shuffle, repeatedly having it shuffle its previously returned array until the returned (shuffled) array is identical (equal) to the original array that was first shuffled. So, your loop would contain a statement like the following: shuffledArray shuffle( shuffledArray ); 1,903 DEC étv LO
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education