Produce a method that combines elements from two LinkedLists of the same size, alternating between them. This
Question:
Produce a method that combines elements from two LinkedLists of the same size, alternating between them. This must be done using the following methods from the Queue Interface: add(), remove(), and peek(). Call this method: combine
Parameter(s): LinkedList, LinkedList
Returns: LinkedList
Ex. Input (as LinkedList elements): ["COMP", "HIST", "MATH", "THEO"] and ["123", "170", "271", "272"], Output: [COMP, 123, HIST, 170, MATH, 271, THEO, 272]
This is the code I have so far, I need help finishing it:
import java.util.*;
class Main { public static void main(String[] args) { //code for testing /* LinkedList class_name = new LinkedList(); class_name.add("BIOL"); class_name.add("THEO"); class_name.add("CHEM"); class_name.add("COMP"); LinkedList numbers = new LinkedList(); numbers.add("456"); numbers.add("170"); numbers.add("781"); numbers.add("100"); System.out.println(class_name); System.out.println(numbers); System.out.println(combine(class_name, numbers)); */ } //Add your code here
}
Accounting Information Systems
ISBN: 9780132871938
11th Edition
Authors: George H. Bodnar, William S. Hopwood