Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

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.

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 data set whose nodes are described in Exercise 19. Include error checking in the code of the basic operation methods, a constructor to permit the client to specify the maximum size of the data set, and a method to display the contents of entire data set in sorted order. Here is the code from #19 to reference. Thanks!

package studentlistings; import javax.swing.JOptionPane;

public class StudentListings { private String name; private String number; private String gpa; public StudentListings() { name = ""; number = ""; gpa = ""; } public String toString() { return("Name is " + name + " Number is " + number + " GPA is " + gpa ); } public StudentListings deepCopy() { StudentListings clone = new StudentListings(); return clone; } public int compareTo(String targetKey) { return (name.compareTo(targetKey)); } public void input() { name = JOptionPane.showInputDialog("Please enter the name: "); number = JOptionPane.showInputDialog("Please enter a number"); gpa = JOptionPane.showInputDialog("Please enter a GPA:"); } public static void main(String[] args) { StudentListings studentList = new StudentListings(); studentList.input(); System.out.println(studentList.toString()); int name=studentList.compareTo("Jane Doe"); studentList.deepCopy(); if(name==0) { System.out.println("This name is already in the database"); } else System.out.println("This name has been added to the database"); } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

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

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions