Question
1. The application class The application class that keeps track of student information at your college: names, identification numbers, and grade point averages. When launched,
1. The application class
The application class that keeps track of student information at your college: names, identification numbers, and grade point averages.
When launched, the user will be asked to input the maximum size of the data set, the initial number of students and the initial data set. Once this is complete, the user will be presented with the following menu: Enter: 1 to insert a new student's information, 2 to fetch and output a student's information, 3 to delete a student's information, 4 to update a student's information, 5 to output all the student information, 6 to exit the program
2. .The application (main) class is given, use the data structure class described(given below-UOAUTILITIES). Begin by coding the portion of it described below and test/debug that code. When the user selects an operation from the menu, simply output a message stating that the operation was performed (e.g. Delete operation performed) to a message box and redisplay the menu. You will complete the application (below).
// declare the data structure and load the initial data set
// input and parsing of the maximum number of nodes, max
// input and parsing of the initial number of students, n
// solicit and perform user requested operations on the data set
// output the menu to an input dialog box
// parse the menu choice into an integer
// while (true)
// { switch statement with six cases to output the operation selected or invoke System.exit(0)
// output the menu input dialog box
// parse the menu choice into an integer
// }
3. The completed application class (Application dependent: Student database at our college)
Complete the application begun above, as describes below. Test and debug it. Be sure to inform the user of success the success or failure to complete the requested operation, inside each case of the switch statement.
// declare the data structure object and load the initial data set
// input and parsing of the maximum number of nodes, max
// declare an object in the data structure class (defined in Step 2) and pass max to its constructor
// input of the initial number of students, n
// declare an object in the node definition class (defined in Step 1)
// a for loop that
// executes n times invoking the StudentListing classs input method (see pg 102)
// Invokd the insert method and then insert the StudentListing node to the data structure
// perform user requested operations on the data set
// output the menu to a message box
// parse the menu choice into an integer
// while (true)
// { switch statement to invoke insert, fetch, delete, update,
// showAll,//in the data structure class, or System.exit(0)
// output the menu message box
// parse the menu choice into an integer
// }
4. Modify the data structure class so that it expands (doubles in size) when full
public class UOAUtilities { private int next; private int size; private StudentListing[ ] data;
public UOAUtilities ( ) { next = 0; size = 100; data = new StudentListing[size]; }//end of constructor
public UOAUtilities (int s) { next = 0; data = new StudentListing[s]; size = s; }//end of constructor
public boolean insert(StudentListing newNode) { if(next >= size) // the structure is full return false; data[next]= newNode.deepCopy( ); // store a deep copy of the clients node if(data[next] == null) return false; next = next + 1; // prepare for the next insert return true; }// end of insert method
public StudentListing fetch(String targetKey) { StudentListing node; StudentListing temp; // access the node using a sequential search int i = 0; while ( i < next && !(data[i].compareTo(targetKey) == 0)) { i++; } if(i== next) // node not found return null; //deep copy the node's information into the client's node node = data[i].deepCopy( ); // move the node up one position in the array, unless it is the first node if(i != 0) // bubble-up accessed node { temp = data[i-1]; data[i-1] = data[i]; data[i] = temp; } return node; } // end of fetch method
public boolean delete(String targetKey) {// access the node using a sequential search int i = 0; while (i < next && !(data[i].compareTo(targetKey) == 0)) { i++; } if(i == next) // node not found return false; //move the last node into the deleted node's position data[ i] = data[ next -1]; data[next-1] = null; next = next - 1; return true; // node found and deleted }//end of the delete method
public boolean update(String targetKey, StudentListing newNode) { if(delete(targetKey) == false) // node not in the structure return false; else if( insert(newNode ) == false) // insufficient memory return false; else return true; // node found and updated }// end of update method public void showAll( ) { for(int i = 0; i< next; i++) System.out.println(data[i].toString( )); }// end showAll method }//end of class UOAUtilities
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started