Question: Must be in JAVA language Integer cabinetCount is read from input as the number of input values that follow. The node headCabinet is created with

Must be in JAVA language
Integer cabinetCount is read from input as the number of input values that follow. The node headCabinet is created with the string "color". Use scnr.next() to read cabinetCount strings. Insert a CabinetNode for each string at the end of the linked list.
Ex: If the input is2 scarlet lavender, then the output is:
color
scarlet
lavender
import java.util.Scanner;
public class CabinetLinkedList {
public static void main(String[] args){
Scanner scnr = new Scanner(System.in);
CabinetNode headCabinet = null;
CabinetNode currCabinet = null;
CabinetNode lastCabinet = null;
int cabinetCount;
String inputValue;
int i;
cabinetCount = scnr.nextInt();
headCabinet = new CabinetNode("color");
lastCabinet = headCabinet;
****** Your code goes here *******
currCabinet = headCabinet;
while (currCabinet != null){
currCabinet.printNodeData();
currCabinet = currCabinet.getNext();
}
}
}

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!