Data Structures and Algorithms in Java – NetBeans
Q: Write a method averge the element of the list in this classin the function place in the comment?
import java.util.*;
public class averageList{
static Scanner console = new Scanner(System.in);
public static void main(String[] args) {
DoublyLinkedList myList = new DoublyLinkedList();
int element;
int list_size;
while(true){
System.out.println(“Enter element(999 to stop):”);
element = console.nextInt();
if(element==999)
break;
myList.addFirst(element);
}
System.out.println(myList);
} // End of main
}// End of class Lab02_EX8
class DoublyLinkedList {
private Node header;
private Node trailer;
private int size = 0;
public DoublyLinkedList() {
header = new Node (0, null, null);
trailer = new Node(0, header, null);
header.setNext(trailer);
}
public int size() { return size; }
public boolean isEmpty() { return size == 0; }
public int getFirst() {
return
PayPal Gateway not configured
PayPal Gateway not configured