For this practice lab you will need to download the starter code. This code contains a class called LinkedList with two methods implemented-add and print. There is also a class called Driver, which has a main method that creates a new list, adds some items, and prints them out. Your task is to write a third method in the Linked List class, called printWithSkips. This method should have the following behavior: Prints the first item in the list, skips zero Prints the second item in the list, skips one Prints the fourth item in the list, skips two Prints the seventh item in the list, skips three ... and so on until it reaches the end of the list Note: Be sure to handle the case where the last item in the full list is not one that should be printed.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

starter code: in java pls and thank you!

public class LinkedList {

    private Node head;
    private Node tail;
   
    public void add(String item) {
       
        Node newItem = new Node(item);
       
        // handles the case where the new item
        // is the only thing in the list
        if (head == null) {
            head = newItem;
            tail = newItem;
            return;
        }
       
        tail.next = newItem;
        tail = newItem;
    }
   
   
    public void print() {
        Node current = head;
        while (current != null) {
            System.out.println(current.item);
            current = current.next;
        }
    }
   
   
    public void printWithSkips() {
        // TODO your code here
    }

   
    class Node {
        String item;
        Node next;
       
        public Node(String item) {
            this.item = item;
            this.next = null;
        }
    }
}
and 
public class Driver {

    public static void main(String[] args) {
        LinkedList list = new LinkedList();
        list.add("Falcons");
        list.add("Bears");
        list.add("Titans");
        list.add("Eagles");
        list.add("Panthers");
        list.add("Cowboys");
        list.add("Steelers");
        list.add("49ers");
        list.add("Vikings");
        list.add("Saints");
        list.add("Seahawks");
       
        list.print();
        System.out.println("\n");
        list.printWithSkips();
    }
}
!!!
PDF
Skipping through a List (1).pdf X +
50
79°F
Clear
1
File C:/Users/19377/Downloads/Skipping%20through%20a%20List%20(1).pdf
T
For this practice lab you will need to download the starter code. This code contains a class called
Linked List with two methods implemented - add and print. There is also a class called Driver, which has
a main method that creates a new list, adds some items, and prints them out.
Your task is to write a third method in the LinkedList class, called printWithSkips. This method should
have the following behavior:
Prints the first item in the list, skips zero
Prints the second item in the list, skips one
Prints the fourth item in the list, skips two
Prints the seventh item in the list, skips three
and so on until it reaches the end of the list
Note: Be sure to handle the case where the last item in the full list is not one that should be printed.
Example output:
Full List:
Falcons
Bears
Titans
Eagles
Panthers
Cowboys
Steelers
➡ | D | A | Ⓡ
→
T
49ers
Vikings
Saints
Seahawks
Print with skips:
Falcons
Bears
Eagles
Steelers
Seahawks
W
|
1+
11:10 PM
6/30/2022
O
+
A
Transcribed Image Text:!!! PDF Skipping through a List (1).pdf X + 50 79°F Clear 1 File C:/Users/19377/Downloads/Skipping%20through%20a%20List%20(1).pdf T For this practice lab you will need to download the starter code. This code contains a class called Linked List with two methods implemented - add and print. There is also a class called Driver, which has a main method that creates a new list, adds some items, and prints them out. Your task is to write a third method in the LinkedList class, called printWithSkips. This method should have the following behavior: Prints the first item in the list, skips zero Prints the second item in the list, skips one Prints the fourth item in the list, skips two Prints the seventh item in the list, skips three and so on until it reaches the end of the list Note: Be sure to handle the case where the last item in the full list is not one that should be printed. Example output: Full List: Falcons Bears Titans Eagles Panthers Cowboys Steelers ➡ | D | A | Ⓡ → T 49ers Vikings Saints Seahawks Print with skips: Falcons Bears Eagles Steelers Seahawks W | 1+ 11:10 PM 6/30/2022 O + A
Expert Solution
steps

Step by step

Solved in 3 steps with 4 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY