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

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

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

You can implement the combine method as follows import javautil class Main public static void main... View full answer

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!