subject

Grocery shopping list (LinkedList) Given a ListItem class, complete main() using the built-in LinkedList type to create a linked list called shoppingList. The program should read items from input (ending with -1), adding each item to shoppingList, and output each item in shoppingList using the printNodeData() method.

Ex. If the input is:

milk
bread
eggs
waffles
cereal
-1

the output is:

milk
bread
eggs
waffles
cereal

---ShoppingList. java:
import java. util. Scanner;
import java. util. LinkedList;

public class ShoppingList {
public static void main (String[] args) {
Scanner scnr = new Scanner(System. in);

// TODO: Declare a LinkedList called shoppingList of type ListItem

String item;

// TODO: Scan inputs (items) and add them to the shoppingList LinkedList
// Read inputs until a -1 is input

// TODO: Print the shoppingList LinkedList using the printNodeData() method

}
}

---ListItem. java:
public class ListItem {
private String item;

public ListItem() {
item = "";
}

public ListItem(String itemInit) {
this. item = itemInit;
}

// Print this node
public void printNodeData() {
System. out. println(this. item);
}
}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 01:10
Are special combinations of keys that tell a computer to perform a command. keypads multi-keys combinations shortcuts
Answers: 1
question
Computers and Technology, 23.06.2019 19:00
Acompany is hiring professionals for web designing. the firm is small with few resources. they want employees who possess problem-solving skills and can independently carry out responsibilities. which kind of employee should they select?
Answers: 2
question
Computers and Technology, 24.06.2019 10:30
This device directs network traffic. bridge hub nic repeater router switch
Answers: 3
question
Computers and Technology, 24.06.2019 13:00
Why should you evaluate trends when thinking about a career path?
Answers: 1
You know the right answer?
Grocery shopping list (LinkedList) Given a ListItem class, complete main() using the built-in Linke...
Questions
question
Mathematics, 07.05.2020 04:08
Questions on the website: 13722361