2.3k views
3 votes
Code an application program that keeps track of student informationat your college . Include their name, identification numbers, and grade point averages in a fully encapsulated homogenous singly linked list. When launched the user will be asked to input 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, and
6 to exit the program.

The program should perform an unlimited number of operations until the user enters a 6 to exit the program. If the user requests an operation on a node not in the structure, the program output should be "node not in structure." Otherwise, the message "operation complete" should be output.

User Denesha
by
3.9k points

1 Answer

6 votes

Answer:

The full code is added in the comments as per regulations. Continuation of driver.java code from the comments is available on the screenshot

Step-by-step explanation:

Editable code:

//ListingNode.java

class ListingNode {

private listpro listing11;

private ListingNode nextnode;

public ListingNode(listpro listing11) {

this.listing11 = listing11;

}

public listpro getListing() {

return listing11;

}

public void setListing(listpro listing11) {

this.listing11 = listing11;

}

public ListingNode getnextnode() {

return nextnode;

}

public void setnextnode(ListingNode nextnode) {

this.nextnode = nextnode;

}

}

public class Listlinked {

private ListingNode headnode;

public Listlinked() {

headnode = null;

}

public void insert(listpro listing11) {

ListingNode listingNode = new ListingNode(listing11);

if(headnode == null) {

headnode = listingNode;

} else {

ListingNode tempval = headnode;

while (tempval.getnextnode() != null) {

tempval = tempval.getnextnode();

}

tempval.setnextnode(listingNode);

}

}

public listpro fetch(String name) {

ListingNode tempval = headnode;

while (tempval != null) {

if(tempval.getListing().getNamedata().equalsIgnoreCase(name)) {

return tempval.getListing();

}

tempval = tempval.getnextnode();

}

return null;

}

public boolean delete(String name) {

ListingNode tempval = headnode;

boolean found = false;

if(headnode != null) {

if(headnode.getListing().getNamedata().equalsIgnoreCase(name)) {

headnode = headnode.getnextnode();

found = true;

} else {

while (tempval.getnextnode() != null) {

if (tempval.getnextnode().getListing().getNamedata().equalsIgnoreCase(name)) {

found = true;

tempval.setnextnode(tempval.getnextnode().getnextnode());

break;

}

tempval = tempval.getnextnode();

}

}

}

return found;

}

public void printAll() {

ListingNode tempval = headnode;

while (tempval != null) {

System.out.println(tempval.getListing().toString());

tempval = tempval.getnextnode();

}

}

}

//listpro.java

import javax.swing.*;

public class listpro {

private String Name;

private int ID;

private float grade_point;

public listpro(){

}

public listpro(String Name, int ID, float grade_point){

this.Name = Name;

this.ID = ID;

this.grade_point = grade_point;

}

public String getNamedata() {

return Name;

}

public void setNamedata(String Name) {

this.Name = Name;

}

public int getID() {

return ID;

}

public void setID(int ID) {

this.ID = ID;

}

public float getgrade_point() {

return grade_point;

}

public void setgrade_point(float grade_point) {

this.grade_point = grade_point;

}

public listpro deepCopy(){

listpro clone = new listpro(Name,ID,grade_point);

return clone;

}

public String toString(){

return "Name : " + Name + "\\ID :" + ID + "\\Grade points :" + grade_point;

}

public void input(){

Name = JOptionPane.showInputDialog("Enter a Name");

ID = Integer.parseInt(JOptionPane.showInputDialog("Enter an ID"));

grade_point = Float.parseFloat(JOptionPane.showInputDialog("Enter a grade point average"));

}

}

Code an application program that keeps track of student informationat your college-example-1
User BorisD
by
4.7k points