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, 21.06.2019 17:20
What do you need to know & understand about global expansion.
Answers: 2
question
Computers and Technology, 24.06.2019 03:00
What is one potential problem associated with an organization purchasing new technology early in its lifecycle
Answers: 1
question
Computers and Technology, 24.06.2019 14:40
Create a function (prob3_6) that will do the following: input a positive scalar integer x. if x is odd, multiply it by 3 and add 1. if the given x is even, divide it by 2. repeat this rule on the new value until you get 1, if ever. your program will output how many operations it had to perform to get to 1 and the largest number along the way. for example, start with the number 3: because 3 is odd, we multiply by 3 and add 1 giving us 10. 10 is even so we divide it by 2, giving us 5. 5 is odd so we multiply by 3 and add one, giving us 16. we divide 16 (even) by two giving 8. we divide 8 (even) by two giving 4. we divide 4 (even) by two giving 2. we divide 2 (even) by 2 to give us 1. once we have one, we stop. this example took seven operations to get to one. the largest number we had along the way was 16. every value of n that anyone has ever checked eventually leads to 1, but it is an open mathematical problem (known as the collatz conjectureopens in new tab) whether every value of n eventually leads to 1. your program should include a while loop and an if-statement.
Answers: 3
question
Computers and Technology, 25.06.2019 04:10
8. create an abstract student class for parker university. the class contains fields for student id number, last name, and annual tuition. include a constructor that requires parameters for the id number and name. include get and set methods for each field; the settuition() method is abstract. create three student subclasses named undergraduatestudent, graduatestudent, and studentatlarge, each with a unique settuition() method. tuition for an undergraduatestudent is $4,000 per semester, tuition for a graduatestudent is $6,000 per semester, and tuition for a studentatlarge is $2,000 per semester. write an application that creates an array of at least six objects to demonstrate how the methods work for objects for each student type. save the files as student.java, undergraduatestudent.java, graduatestudent.java, studentatlarge.java, and studentdemo.java.
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, 26.02.2021 22:50
question
Mathematics, 26.02.2021 22:50
question
Social Studies, 26.02.2021 22:50
Questions on the website: 13722361