Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is an Individual Assignment. You must complete this assignment on your own. - Do not collaborate or share code with other students. - Do

image text in transcribed
image text in transcribed
This is an Individual Assignment. You must complete this assignment on your own. - Do not collaborate or share code with other students. - Do not copy and paste code from anywhere. - Do not use any resources outside of those provided in the course materials. - Do not use any language features that have not been covered to this point in the course materials. - If you get stuck or need help, please use the help systems provided in this course. Required Skills Inventory - Write a method that takes an argument and returns a value - Write a method that takes an array as an argument - Write a method that returns an array - Use a loop to iterate over the elements of an array - Use an index value to access an array element - Use an if statement to get the computer to make a decision - Copy values from one array to another - Declare and instantiate an array Problem Description and Given Info Write (define) a public stat ic method named getAlLess Than, that tokes an array of int, and an int as arguments and returns a an int array with all of the values in the argument array that are less than the second argument value. For example, given the following Array declaration and instantiation: Int:()myArray=(1,22,333,400,5005,9)} getAlLLessThan (myArray, 30e) will return an Array of int with these values {1,22,9} Problem Description and Given Info Write (define) a public static method named getAlLess Than, that takes an array of int, and an int as arguments and returns a an int array with all of the values in the argument array that are less than the second argument value. For example, given the following Array declaration and instantiation: int[]myArray=(1,22,333,400,5005,9); getAlLLess Than (myArray, 300) will retum an Array of int with these values {1,22,9} Note that the values in the returned array must be in the same order as they are in the argument array. You may wish to write some additional code to test your method. Copyright 2021 Arizona State University - THIS CONTENT IS PROTECTED AND MAY NOT BE SHARED, UPLOADED, SOLD, OR DISTRIBUTED Helpful Hints: - Your method will need to declare and instantiate a new array to store all of the elements in the argument array, except the last. element. - Your method will first need to count the number of elements in the argument array that meet the criteria, so that you know the size of the new array that you will need to instantiate - Use a loop to iterate through all elements in the argument array, and copy each one into the new array only if the value meets the criteria - The values copied from the argument array into the new array will likely not be stored at the same index in both arrays, therefore, your method will need to keep track of both indexes - the index in the argument array that you are currently looking at, and the index in the new array where the next value will be stored

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_2

Step: 3

blur-text-image_3

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

The Database Experts Guide To Database 2

Authors: Bruce L. Larson

1st Edition

0070232679, 978-0070232679

More Books

Students also viewed these Databases questions