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

Using the provided StudentNode, GradebookLinkedList, and GradebookTest files, co

ID: 3812797 • Letter: U

Question

Using the provided StudentNode, GradebookLinkedList, and GradebookTest files, complete the necessary code to develop a linked list data structure for a gradebook application that can dynamically add more data for students first name, last name, ID and exam score. The GradebookTest file is complete and contains the data for the output below (this is where the main method is located) -hint: study the file GradebookTest and complete the file StudentNode before the GradebookLinkedList file

// Name:
// Date:

public class GradebookTest
{

public static void main(String[] args)
   {
  
           StudentNode studentNodePtr;                               // initialize StudentNode variable
           GradebookLinkedList list = new GradebookLinkedList();   // initialize and call constructor for GradebookLinkedList
          
           // add data dynamically to the linked list
list.add("John", "Doe", 1001, 80.5);
list.add("Sally", "Joe", 1104, 98.0);
list.add("Tommy", "Toe", 1051, 66.5);
           list.add("Patty", "May", 1211, 77.0);
           list.add("Peggy", "Sue", 1555, 91.3);
           list.add("Clark", "Kent", 1051, 66.5);
           list.add("Roger", "West", 1171, 99.9);
  
           System.out.println();
          
           studentNodePtr = list.getHead();                   // set StudentNode to the "head" node
          
           // loop through all data elements and print contents
           for(int i=0; i < list.size(); i++)
           {
               System.out.printf("%s %s (ID: %d) Exam Score = %.2f ", studentNodePtr.getFirstName(), studentNodePtr.getLastName(), studentNodePtr.getId(), studentNodePtr.getExamOne());
               studentNodePtr = studentNodePtr.getNext();       // set StudentNode to the next node
           }
          
           // call and print the linked list method to find the exams average
           System.out.printf(" Average Scores for Exam = %.2f ", list.examAvg() );
}
  
}   // end GradebookTest class

// Name:
// Date:

public class StudentNode
{
// initialize class variables
   private String firstName;
   private String lastName;
private Integer id;
   private Double examOne;
private StudentNode next;
  
// constructor method
   public StudentNode(String firstName, String lastName, Integer id, Double examOne)
   {
this.firstName = firstName;
this.lastName = lastName;
       this.id = id;
       this.examOne = examOne;
this.next = null;
}

   // *** COMPLETE THE SET AND GET METHODS FOR THE CLASS ATTRIBUTES LISTED ABOVE ***
  
   // get method for firstName
public String getFirstName()
   {
// *** PROVIDE CODE HERE ***
}

   // set method for firstName
public void setFirstName(String firstName)
   {
// *** PROVIDE CODE HERE ***
}
  
   // get method for lastName
public String getLastName()
   {
// *** PROVIDE CODE HERE ***
}

   // set method for lastName
public void setLastName(String lastName)
   {
// *** PROVIDE CODE HERE ***
}

   // get method for id
public Integer getId()
   {
// *** PROVIDE CODE HERE ***
}

   // set method for id
public void setId(Integer id)
   {
// *** PROVIDE CODE HERE ***
}
  
   // get method for the examOne
   public Double getExamOne()
   {
// *** PROVIDE CODE HERE ***
   }

   // set method for examOne
   public void setExamOne(Double examOne)
   {
// *** PROVIDE CODE HERE ***
   }

// get method for the next node
   public StudentNode getNext()
   {
// *** PROVIDE CODE HERE ***
}
  
   // set method for the next node
public void setNext(StudentNode next)
   {
// *** PROVIDE CODE HERE ***
}
  
}   // end StudentNode class

// Name:
// Date:

public class GradebookLinkedList
{
// initialize class variable
private StudentNode head;
  
   // empty constructor method
public GradebookLinkedList()
   {
}

   // get method to linked list "head" node
public StudentNode getHead()
   {
// *** PROVIDE CODE HERE ***
}

   // set method to linked list "head" node
public void setHead(StudentNode head)
   {
// *** PROVIDE CODE HERE ***
}
  
   // method to check if the linked list is empty
public boolean isEmpty()
   {
       // *** PROVIDE CODE HERE ***
}
  
   // method to add data to the linked list
public void add(String firstName, String lastName, Integer id, Double examOne)
   {
       // *** PROVIDE CODE HERE ***
}

   // method to return the size of the linked list
   public Integer size()
   {
       // *** PROVIDE CODE HERE ***
}
  
   // method to calculate the average exam score
   public Double examAvg()
   {
       // *** PROVIDE CODE HERE ***  
   }
     
}   // end GradebookLinkedList class

Sample John Doe (ID: 1001) Exam Score 80.50 Sally Joe (ID: 1104) Exam SC 98.00 Ore Exam score 66.50 Tommy Toe (ID: 1051) Patty May (ID: 1211) Exam Score 77.00 Peggy Sue (ID: 555 Exam Score 91.30 Clark Kent (ID: 1051) Exam Score 66.50 Roger West (ID: 1171) Exam Score 99.90 Average scores for Exam 82.81

Explanation / Answer

HI, Please find my implementation.

#####################

public class StudentNode

{

   // initialize class variables

   private String firstName;

   private String lastName;

   private Integer id;

   private Double examOne;

   private StudentNode next;

   // constructor method

   public StudentNode(String firstName, String lastName, Integer id, Double examOne)

   {

       this.firstName = firstName;

       this.lastName = lastName;

       this.id = id;

       this.examOne = examOne;

       this.next = null;

   }

   // *** COMPLETE THE SET AND GET METHODS FOR THE CLASS ATTRIBUTES LISTED ABOVE ***

   // get method for firstName

   public String getFirstName()

   {

       // *** PROVIDE CODE HERE ***

       return firstName;

   }

   // set method for firstName

   public void setFirstName(String firstName)

   {

       // *** PROVIDE CODE HERE ***

       this.firstName = firstName;

   }

   // get method for lastName

   public String getLastName()

   {

       // *** PROVIDE CODE HERE ***

       return lastName;

   }

   // set method for lastName

   public void setLastName(String lastName)

   {

       // *** PROVIDE CODE HERE ***

       this.lastName = lastName;

   }

   // get method for id

   public Integer getId()

   {

       // *** PROVIDE CODE HERE ***

       return id;

   }

   // set method for id

   public void setId(Integer id)

   {

       // *** PROVIDE CODE HERE ***

       this.id = id;

   }

   // get method for the examOne

   public Double getExamOne()

   {

       // *** PROVIDE CODE HERE ***

       return examOne;

   }

   // set method for examOne

   public void setExamOne(Double examOne)

   {

       // *** PROVIDE CODE HERE ***

       this.examOne = examOne;

   }

   // get method for the next node

   public StudentNode getNext()

   {

       // *** PROVIDE CODE HERE ***

       return next;

   }

   // set method for the next node

   public void setNext(StudentNode next)

   {

       // *** PROVIDE CODE HERE ***

       this.next = next;

   }

} // end StudentNode class

#########################

public class GradebookLinkedList

{

   // initialize class variable

   private StudentNode head;

   // empty constructor method

   public GradebookLinkedList()

   {

       head = null;

   }

   // get method to linked list "head" node

   public StudentNode getHead()

   {

       // *** PROVIDE CODE HERE ***

       return head;

   }

   // set method to linked list "head" node

   public void setHead(StudentNode head)

   {

       // *** PROVIDE CODE HERE ***

       this.head= head;

   }

   // method to check if the linked list is empty

   public boolean isEmpty()

   {

       // *** PROVIDE CODE HERE ***

       return head==null;

   }

   // method to add data to the linked list

   public void add(String firstName, String lastName, Integer id, Double examOne)

   {

       // *** PROVIDE CODE HERE ***

       StudentNode s = new StudentNode(firstName, lastName, id, examOne);

       s.setNext(head);

       head = s;

      

   }

   // method to return the size of the linked list

   public Integer size()

   {

       // *** PROVIDE CODE HERE ***

       StudentNode temp = head;

       int count = 0;

       while(temp != null){

           count++;

           temp = temp.getNext();

       }

      

       return count;

   }

   // method to calculate the average exam score

   public Double examAvg()

   {

       // *** PROVIDE CODE HERE ***

       StudentNode temp = head;

       int count = 0;

       double sum = 0;

       while(temp != null){

           count++;

           sum = sum + temp.getExamOne();

           temp = temp.getNext();

       }

      

       return sum/count;

   }

} // end GradebookLinkedList class

##########################

public class GradebookTest

{

   public static void main(String[] args)

   {

       StudentNode studentNodePtr; // initialize StudentNode variable

       GradebookLinkedList list = new GradebookLinkedList(); // initialize and call constructor for GradebookLinkedList

       // add data dynamically to the linked list

       list.add("John", "Doe", 1001, 80.5);

       list.add("Sally", "Joe", 1104, 98.0);

       list.add("Tommy", "Toe", 1051, 66.5);

       list.add("Patty", "May", 1211, 77.0);

       list.add("Peggy", "Sue", 1555, 91.3);

       list.add("Clark", "Kent", 1051, 66.5);

       list.add("Roger", "West", 1171, 99.9);

       System.out.println();

       studentNodePtr = list.getHead(); // set StudentNode to the "head" node

       // loop through all data elements and print contents

       for(int i=0; i < list.size(); i++)

       {

           System.out.printf("%s %s (ID: %d) Exam Score = %.2f ", studentNodePtr.getFirstName(), studentNodePtr.getLastName(), studentNodePtr.getId(), studentNodePtr.getExamOne());

           studentNodePtr = studentNodePtr.getNext(); // set StudentNode to the next node

       }

       // call and print the linked list method to find the exams average

       System.out.printf(" Average Scores for Exam = %.2f ", list.examAvg() );

   }

} // end GradebookTest class

/*

Sample run:

Roger West   (ID: 1171)   Exam Score = 99.90

Clark Kent   (ID: 1051)   Exam Score = 66.50

Peggy Sue   (ID: 1555)   Exam Score = 91.30

Patty May   (ID: 1211)   Exam Score = 77.00

Tommy Toe   (ID: 1051)   Exam Score = 66.50

Sally Joe   (ID: 1104)   Exam Score = 98.00

John Doe   (ID: 1001)   Exam Score = 80.50

Average Scores for Exam = 82.81

*/