further below is the actual problem. *For the entirety of this question you are not allowed to
Question:
further below is the actual problem.
*For the entirety of this question you are not allowed to use any data structure * other than a custom built linked list. This should consist ONLY of a node * class that will be given. You should not be creating a secondary class to handle the data * structure. * * Failure to do so will result in no credit.
the node class
public class Node
public Node(E item, Node
public E getItem() { return item; }
public void setItem(E item) { this.item = item; }
public Node
public void setNext(Node
}
the problem: THIS IS WHERE I AM STUCK, PLEASE READ THE PROBLEM. * Problem: Given a Linked List of Integers you print from problem A (PPROBLEM A IS BELOW THIS CODE), count the number of numbers that contain 4 in the list. A number can have multiple 4s, but it still only counts as 1 number. i.e. The list [3, 54, 4, 444, 49] has 4 numbers with the number 4. Return your final count. DO NOT MAKE ANY OTHER METHODS OR CLASSES AND DO NOT CHANGE ANY OF THE METHOD HEADERS OR CLASSES */
public int countNumbersWith4(Node
//this code does not work and returns zero, if I enter numbers with 4.
PROBLEM A:
public Node
Node
if(userInput.hasNextInt()) { int numInput = userInput.nextInt(); if (start == null) { start = new Node<>(numInput, null); tail = start; } else { Node
Microeconomics An Intuitive Approach with Calculus
ISBN: 978-0538453257
1st edition
Authors: Thomas Nechyba