Question: Step 1 : Inspect the NumberListNode.java file Inspect the class declaration for a doubly - linked list node in NumberListNode.java. The NumberListNode class has three

Step 1: Inspect the NumberListNode.java file
Inspect the class declaration for a doubly-linked list node in NumberListNode.java. The NumberListNode class has three fields:
data: A double for the node's numerical data value
next: A reference to the next node
previous. A reference to the previous node
Each field is protected. So code outside of the class must use the provided getter and setter methods to get or set a field.
NumberListNode.java is read-only since no changes are required.
Step 2: Inspect NumberList.java and SortedNumberList.java
NumberList.java contains the NumberList class definition. NumberList is a base class for a double-linked list of NumberListNodes. The
list's head and tail fields are protected, and a printo utility method exists to print the list s contents from head to tail. The file is read-only
since no changes are required.
SortedNumberList.java contains the SortedNumberList class definition. SortedNumberList extends NumberList and adds insert() and
remove() methods.
Step 3: Implement insert()
Implement SortedNumberLists insert0 method to create a new node with the number argument as the node s data then insert the
node into the proper sorted position in the linked list. Ex Suppose a SortedNumberlists sument sist 15.2347.2586
then insert ) is called. A new node with data value 33.5 screated and inserted between 23 and 43.25 thus preserving the list's
sorted order and yielding: 2335.547.2586
Step 4: Run code and verify output
An array of doubles named numbersTolnsert is defined near the start of main(). Each is inserted into a SortedNumberList, and the list is
printed after each insertion. Try changing the array's content, and verify that each output is a sorted list.
Step 5: Implement remove()
Implement SortedNumberList's remove( method. The method takes an argument for the number to remove from the list. If the number
does not exist in the list, the list is not changed and false is returned. Otherwise, the first instance of the number is removed from the
list and true is returned.
Once remove( is implemented, change the value of the includeRemovals variable, defined at the start of main 0, from false to true. Run
the code and make sure that the list is correct after each removal.
Try different tests in main() as needed then submit code for grading. Unit tests are used to grade submitted code, so output from
main( does not affect grading.
IDE settings requiring a reload have been updated. Click here to reload the IDE.
Files
Main,java
Main.java
NumberList,java
boolean includeRemovals = false;
1, Numbers to insent duning finst Loop:
double[] numberstoInsent =f7.75,15.25,-4.25,63,5,18.25,-3,5
NumberListNode.java
Main.java
1 import java.util.Scanner;
import java.io.PrintWriter;
public class Main {
public static void main(String[] args){
boolean includeRemovals = false;
// Numbers to insert during first loop:
double[] numbersToInsert ={
77.75,15.25,-4.25,63.5,18.25,-3.5
};
// Insert each value and show the sorted list's contents after ea
SortedNumberList list = new SortedNumberList();
for (double number : numbersToInsert){
for (double number : numbersToInsert){
System.out.print("List after inserting "+ number +": ");
list.insert(number);
list.print(System.out);
}
If (includeRemovals){
System.out.println();
double[] numbersToRemove ={
77.75,// List's last element
-4.25,// List's first element
18.25,// Neither first nor last element
// Remaining elements:
15.25,63.5,-3.5
// Remaining elements:
15.25,63.5,-3.5
};
// Remove numbers
for (double toRemove : numbersToRemove){
System.out.print("List after removing "+ toRemove +": ");
list.remove(toRemove);
list.print(System.out);
}
}
}
}
Step 1 : Inspect the NumberListNode.java file

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!