Question: (Program 1 is below the description of the problem) Program 1: *******MAIN CLASS***************** public static void main(String[] args) { String max; max = JOptionPane.showInputDialog(How many

(Program 1 is below the description of the problem)

(Program 1 is below the description of the problem) Program 1: *******MAINCLASS***************** public static void main(String[] args) { String max; max = JOptionPane.showInputDialog("How

Program 1:

*******MAIN CLASS*****************

public static void main(String[] args) { String max; max = JOptionPane.showInputDialog("How many nodes are going to be in the structure?"); StudentListing s = new StudentListing(); UOAUtilities ds = new UOAUtilities(Integer.parseInt(max)); int n = Integer.parseInt(JOptionPane.showInputDialog("How many students will be input?")); for (int i = 0; i

switch (choice) {

case 1: try { s.input(); ds.insert(s); JOptionPane.showMessageDialog(null, "Operation successfull."); } catch (Exception exception) { JOptionPane.showMessageDialog(null, "Operation failed."); } break; case 2:

s = ds.fetch(JOptionPane.showInputDialog("Please enter the student's name we will be fetching. ")); System.out.println(s); break;

case 3: try { ds.delete(max); JOptionPane.showMessageDialog(null, "Operation successfull."); } catch (Exception exception) { JOptionPane.showMessageDialog(null, "Operation failed."); } break;

case 4: try { String targetKey = JOptionPane.showInputDialog("Student to be Updated?"); s.input(); ds.update(targetKey, s.deepCopy()); JOptionPane.showMessageDialog(null, "Operation successfull."); } catch (Exception exception) { JOptionPane.showMessageDialog(null, "Operation failed."); } break;

case 5: ds.showAll(); break;

case 6: ds.expand(); break;

case 7: System.exit(0);

default: break; } } } }

***************STUDENT LISTING CLASS**********************

import javax.swing.JOptionPane;

public class StudentListing { private String name; private String idNumber; private String gpa;

public StudentListing(String n, String i, String g) { name = n; idNumber = i; gpa = g;

} public StudentListing() { this.name=""; this.idNumber=""; this.gpa=""; }

public String toString() { return("Student name is " + name + " ID Number is " + idNumber +" GPA is " + gpa + " "); } public StudentListing deepCopy() { StudentListing clone = new StudentListing(name, idNumber, gpa); return clone; }

public int compareTo(String targetKey) { return(name.compareTo(targetKey)); }

public void input() { name = JOptionPane.showInputDialog("Enter a Name please. "); idNumber = JOptionPane.showInputDialog("Enter the ID Number please. "); gpa = JOptionPane.showInputDialog("Enter the GPA please. "); } }

***********************UOAUTILITIES CLASS***************************

public class UOAUtilities { private int next; private int size; private StudentListing[] data;

public UOAUtilities() { next = 0; size = 100; data = new StudentListing[size]; }

public UOAUtilities(int s) { next = 0; data = new StudentListing[s]; size = s; } public boolean insert(StudentListing newStudentListing) { if (next >= size) { int count = (int) (size * .2); StudentListing[] tempstudent = new StudentListing[count + size]; for (int i = 0; i

data[next] = newStudentListing.deepCopy();

if (data[next] == null) { return false; } next = next + 1; return true; }

public StudentListing fetch(String targetKey) { StudentListing studentListing; StudentListing temp; int i = 0; while (i

if (i == next) { return null; }

studentListing = data[i].deepCopy();

if (i != 0) { temp = data[i - 1]; data[i - 1] = data[i]; data[i] = temp; }

return studentListing; }

public boolean delete(String targetKey) { int i = 0; while (i

if (i == next) { return false; }

data[i] = data[next - 1]; data[next - 1] = null; next = next - 1; return true;

}

public boolean update(String targetKey, StudentListing newStudentListing) {

if (delete(targetKey) == false) { return false; } else if (insert(newStudentListing) == false) { return false; } else { return true; }

} public void showAll() { for (int i = 0; i

}

public boolean expand() { StudentListing[] temp = data; if (data == null) { data = new StudentListing[size * 2]; } return false;

} }

Re-do Program l (the Unsorted-Optimized Array structure) but this time store the nodes in a sorted, doubly linked list. First convert the singly linked list class to a sorted singly linked list (70% see below). Then convert to a doubly linked (20% 10% see below and read the footnote) Client node definition class changes Add a getKey method to it. Application class changes: Change the class of the data structure object and, eliminate the asking of maximum number of nodes. Data structure class SinglyLinkedList (pg 189) changes: 70% Sorted Singly linked Change the data structure class to the class on pages 189-190, and change the class name and the client's node definition class name from Listing to StudentListings insert (sorted) Add a getKey melod to the StudentListing's class search list for insertion point: while (not at end of list && key

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 Databases Questions!