Create a class that represents a list. Such class should be able to add and remove an element of the list at a given position (index). The class should also be able to print all elements of the list on a straight line splitting each element with a comma.
In order to test the class, write a program that asks for elements to add into the list until the user types -1. Upon receiving a -1, the program should print all the elements of the list.
In computer science, a linked list is a data structure consisting of a group of nodes which together represent a sequence. Under the simplest form, each node is composed of data and a reference (in other words, a link) to the next node in the sequence; more complex variants add additional links. This structure allows for efficient insertion or removal of elements from any position in the sequence.
The program should contain 2 classes, a class LinkedList that represents the whole list and a class Node that represents each element of the list.
The user will input all elements of the list separated by a new line. The last element will be a -1.
The elements of the list on the same line separated by a comma.
9
E
5
2.3
8
-1
9,E,5,2.3,8