Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Now implement the removeOdd method in Java. import java.util.Arrays; public class RemoveTester { / * * Removes all odd elements from a partially filled array

Now implement the removeOdd method in Java. import java.util.Arrays;
public class RemoveTester
{
/**
Removes all odd elements from a partially filled array
@param values a partially filled array
@param size the number of elements in values
@return the new size
*/
public static int removeOdd(int[] values, int size)
{
/* Your code here */
}
public static void main(String[] args)
{
int[] a ={22,98,95,46,31,53,82,24,11,19};
int sizeBefore =8;
int sizeAfter = removeOdd(a, sizeBefore);
System.out.print("a: [");
for (int i =0; i < sizeAfter; i++)
{
System.out.print(a[i]+"");
}
System.out.println("]");
System.out.println("Expected: [2298468224]");
System.out.println();
int[] b ={23,97,95,45,31,53,81,24,11,19};
sizeBefore =7;
sizeAfter = removeOdd(b, sizeBefore);
System.out.print("b: [");
for (int i =0; i < sizeAfter; i++)
{
System.out.print(b[i]+"");
}
System.out.println("]");
System.out.println("Expected: []");
System.out.println();
int[] c ={20,94,92,48,32,54,81,24,11,19};
sizeBefore =4;
sizeAfter = removeOdd(c, sizeBefore);
System.out.print("c: [");
for (int i =0; i < sizeAfter; i++)
{
System.out.print(c[i]+"");
}
System.out.println("]");
System.out.println("Expected: [20,94,92,48]");
}
}

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

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

8th Edition

013460153X, 978-0134601533

More Books

Students also viewed these Databases questions

Question

=+5. What is your impression of the Carbon Principles?

Answered: 1 week ago