The goal for this exercise is to make sure that you can create a simple LinkedList<>, and both put values into it, and get values back out of it.
What you need to do to prepare for this exercise:
In the starter project, add code to the
LinkedList_Basics
class, so that the RunExercise
method does the following:
Create a LinkedList<>
object that can
store integers.
Repeatedly ask user for int
input
(if the user types in a negative number then the
loop should stop). With each input, the
program should do the following:
add the new item to the linked list, in order (smallest values at the front of the list, largest values at the end)
then print out the list
Here is an example transcript (with user input input like this)
Next number? (-1 to exit) 10 Values in the linked list: 10 Next number? (-1 to exit) 5 Values in the linked list: 5 10 Next number? (-1 to exit) 6 Values in the linked list: 5 6 10 Next number? (-1 to exit) 20 Values in the linked list: 5 6 10 20 Next number? (-1 to exit) -1