Question: Odd List & Even List You will be provided with a List of five ( 5 ) integers named numbers and your goal is to

Odd List & Even List
You will be provided with a List of five (5) integers named numbers and your goal is to separate them into new Lists as instructed below:
Create two (2) new Lists called oddNumbers and evenNumbers.
The oddNumbers List should store all the odd integers from numbers
The evenNumbers List should store all the even integers from numbers
Print all three Lists to the console in this order: numbers, oddNumbers, and evenNumbers using the text shown in the Example Output below (e.g. "Original List: ")
import java.util.*;
public class CodingQuestion {
static void halfList(List numbers){
// Declare two new lists to store odd and even numbers
// Separate odd and even numbers into their respective lists
// Print out the original list, the list of odd numbers, and the list of even numbers
}
public static void main(String[] args){
Scanner in = new Scanner(System.in);
List numbers = new ArrayList<>();
for (int i =0; i <5; i++){
int num = in.nextInt();
numbers.add(num);
}
halfList(numbers);
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!