I have created a linked list and I wish for the user to enter a Station and then the output is the number stored for that station.
LinkedList myList = new LinkedList();
myList.addFirst("London", 5);
myList.addNode("Manchester ", 10);
myList.addNode("Liverpool", 20);
myList .addNode("Birmingham", 50);
This is the input for the user to enter.
String name;
name = JOptionPane.showInputDialog("Enter Station: ");
StringNode temp;
temp = mylist.head;
if (temp.Station == (name)) {
System.out.println("Yes");
}
For example if the user inputs London it outputs 5 and if they choose london AND Manchester it outputs 15.
The rest of the methods are just adding a new data and printing.
Thanks