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.

COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
1st Edition
ISBN:9780357392676
Author:FREUND, Steven
Publisher:FREUND, Steven
Chapter4: Financial Functions, Data Tables, And Amortization Schedules
Section: Chapter Questions
Problem 8AYK
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
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
COMPREHENSIVE MICROSOFT OFFICE 365 EXCE
Computer Science
ISBN:
9780357392676
Author:
FREUND, Steven
Publisher:
CENGAGE L