subject

Write the removeEvens() method, which receives an array of integers as a parameter and returns a new array of integers containing only the odd numbers from the original array. The main program outputs values of the returned array. Hint: If the original array has even numbers, then the new array will be smaller in length than the original array and should have no blank element.
Ex: If the array passed to the removeEvens() method is [1, 2, 3, 4, 5, 6, 7, 8, 9], then the method returns and the program output is:
[1, 3, 5, 7, 9]
Ex: If the array passed to the removeEvens() method is [1, 9, 3], then the method returns and the program output is:
[1, 9, 3]
LAB: Remove all even numbers from an array
LabProgram. java L.
1 import java. util. Arrays;
2
3 public class LabProgram {
4
5 public static int[] removeEvens(int [] nums) {
6
7
8 }
9
10 public static void main(String[] args) {
11
12 int [] input {1,2,3,4,5,6,7,8,9};
13 int [] result = removeEvens(input);
14
15 // Helper method Arrays. toString() converts int[] to a String
16 System. out. println(Arrays. toString(result)); // Should print [1, 3, 5, 7, 9]
17 }
18 }

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 07:30
Jasper and samantha are in a robotics competition. the guidelines state that the robots should be able to move a 10-gram weight at least 2 meters and turn in a circle. jasper and samantha have already built the robot. which step of the design process should they follow next to decide whether their robot meets the minimum criteria for the competition?
Answers: 1
question
Computers and Technology, 22.06.2019 10:50
Using least squares fitting, you are to fit the data sets to the following models and solve for the parameters ai , where i is the index of the parameter. the input/output data for the systems are linked in the bblearn site. for each of the systems use matlab to plot the supplied data vs. the model fit on one plot. include your code in the solutions. (a) linear fit "lineardata.mat" y=a1x^3 + a2x^2 + a3x + a4 (b) plant fit "plantdata.mat g(s) = a1/(s + a2)
Answers: 1
question
Computers and Technology, 22.06.2019 13:00
Why the bear has a slunky tail determine the meaning of the word slunk in the story
Answers: 1
question
Computers and Technology, 23.06.2019 12:20
When guido van rossum created python, he wanted to make a language that was more than other programming languages. a. code-based b. human-readable c. complex d. functional
Answers: 1
You know the right answer?
Write the removeEvens() method, which receives an array of integers as a parameter and returns a new...
Questions
question
Mathematics, 17.05.2021 20:20
question
English, 17.05.2021 20:20
question
Mathematics, 17.05.2021 20:20
Questions on the website: 13722361