Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A database is to be developed to keep track of student information at your colle

ID: 3860098 • Letter: A

Question

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.

1 public class Node 2. private String name; key field private String address; private String number; public Node (String n, String a, String num) { name=n; addressa number num : 10 public String tostring return(Name isname InAddress is address + InNumber is number 15. public Node deepCopy( { Node clone= new Node (name, address, number); 17 return clone; 19. public int compareTo (String targetKey) 20 21 22 ublic void setAddress(String a) 1 coded to demonstrate return (name.compareTo(targetKey)); encapsulation 23. address a; 24. 25. public void input() 26 27 28 29 iI end of inputNode method 30. ) end of class Node name-JOptionPane,showInputDialog("Enter a name") address JOptionPane.showInputDialog( Enter an address) number = JOptionPane.showinputDialog ("Enter a number.);

Explanation / Answer

Raw Paste Java Code:

package studentlistings;
import javax.swing.JOptionPane;

//Class definition
public class StudentListings {
  
    //Class variables
   private String Name;
   private int Id_number;
   private double Gpa;

   //Constructor with no parameters
   public StudentListings()
   {
       Name="abc";
       Id_number=1234;
       Gpa=0.0;
   
   }

   //Method tostring definition
   public String toString()
   {
        return("Name is " + Name +" Identification number is " + Id_number +" GPA is " + Gpa+ " ");
   }

   //method deepCopy definition
   public StudentListings deepCopy( )
   {
      StudentListings clone = new StudentListings();
      return clone;
   }

   //Method compareTo definition
   public int compareTo(String targetKey)
   {
       return(Name.compareTo(targetKey));
   }

   //Method input definition
   public void input()
   {
    Name = JOptionPane.showInputDialog("Enter the name");
    Id_number= Integer.parseInt(JOptionPane.showInputDialog("Enter the ID"));
    Gpa = Double.parseDouble(JOptionPane.showInputDialog("Enter the GPA"));
    }

   //Driver main method to test the functions
    public static void main(String[] args) {
      
      StudentListings classlist= new StudentListings();
    
      classlist.input();
    
      System.out.println(classlist.toString());
      int flag=classlist.compareTo("Tom");
      classlist.deepCopy();
      if(flag==0)
      {
          System.out.println("Tom is there in the list");
      }
      else
          System.out.println("Tom is not there in the list");
    
    }
  
}