Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

// JAVA PROGRAMMING LANGUAGE Note: The book makes this sound a little harder than it is. Your goal here is to create a Node class

// JAVA PROGRAMMING LANGUAGEimage text in transcribed

image text in transcribedimage text in transcribedimage text in transcribed

Note: The book makes this sound a little harder than it is. Your goal here is to create a Node class (#19) which represents one student, and then create another class which contains an array of Node objects (#20) and supports insertions, deletions, etc. The important part to learn is knowing how to manually write the dynamic memory allocation of the array as it changes size due to the insertions and deletions. You must use a plain array( Node[] ) and not one ofjava's pre-built classes that handles resizing automatically. The final exercise (#21) is just a demonstration that your array operations work. Programming Exercises 19. A database is to be developed to keep track of student information at your college. It will include names, identification numbers, and grade point averages. The data set will be accessed in the key field mode, with the student's name being the key field. Code a class named StudentListings that defines the nodes. Your class should include all the methods in the class shown in Figure 2.28 except for the setAddress () method. It should also include a no-parameter constructor. Test it with a progressively developed driver program that verifies the functionality of all of its methods. 20. Code a class that implements the Sorted Array structure, and write a progressively developed driver program that verifies the functionality of all of its methods. Assume that it is to store a ta set whose nodes are described in Exercise 19. Include error checking in the code of the 122 Chapter 2: Array-Based Structures basic operation meth ic operation methods, a constructor to permit the client to specify th the data set, and a method to display th data set, and a method to display the contents of entire data set in sorte axinu at your college 21. Code an application program that keeps track of student information identification numbers, and grade point averages in a fully encasu le Sorte darray-baseddata structure, when launched,the user will beaskedeto ( asked to in mog nput the mum size of the data set, the initial number of students, and the initial 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 in sorted order, and 6 to exit the program. The program should perform an unlimited number of operations until the exit the program. user enters a 6to oen track of faculty information at vour colle Chapter 2: Array-Based Structures 1 public class Node 2. private String name; / key rield 3. private String address; 4.private String number 5. 6 public Node (String n, String a, String num) name n addressa numbernum; 9 public String toString() 1. return("Name is +name + 10. 12 13 14 InAddress is address + InNumber is number +n) 15. public Node deepCopy) 16. Node clone new Node (name, address, number); 17 return clone; 18. 19. 20. public int compareTo(String targetKey) return(name.compareTo (targetKey)) public void setAddress(String a) 1/ coded to demonstrate { address=a; public void input() 21 22. // encapsulation 23, 24. 25. 26. 27. 28. 29. 30. name JOptionPane. showInputDialog("Enter a name") address JOptionPane. showInputDialog("Enter an address"); number #JOptionPane .showinputDialog ( "Enter a number.); // end of inputNode method end of class Node Figure 2.28 Recoding of the Class Node to Include a Default Constructor and an input Method The revised code of the Listing class, which has been renamed Node, is given in Figure 2.28. The new input method is coded on Lines 25-29, which places the user input directly into the data members name, address, and number. The revised code of the UnsortedoptimizedArray class, which has been renamed UOAUtilities is given in Figure 2.29 All references to the class Listing now refer to its expanded version, the class Node (e.g., Lines 4 and 18). The new constructor is coded as Lines 12-16. It uses an integer passed into it (the parameter on Line 12) to size the structure's array on Line 14. Since the value of s is also saved in the class data member size (Line 15), no changes are required to the error checking performed in basic oer tion methods (e.g, Line 19)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Lab Manual For Database Development

Authors: Rachelle Reese

1st Custom Edition

1256741736, 978-1256741732

More Books

Students also viewed these Databases questions

Question

What does the symbol p represent in the statement X ~ b(n, p)?

Answered: 1 week ago

Question

Explain the factors influencing wage and salary administration.

Answered: 1 week ago

Question

Examine various types of executive compensation plans.

Answered: 1 week ago

Question

1. What is the meaning and definition of banks ?

Answered: 1 week ago