title: Linked List Student managment system
body: <p>What the program does: So I have a program that is supposed to give the user 4 options...add student, remove student, print student info, and exit. If the user enters 1 then the add student will be selected and it will ask how many students do you want to add. They will then enter how many they need to add and they will fill out everything needed by the student class for each added. If option 2 is selected then it will remove a student from the linked list by name. If option 3 is selected then it will only print out the students name, zip, and major (the others are to be used in a different project). If option 4 is selected it will exit. It will keep displaying this menu until 4 is selected.</p>
  
  <p>What my issue is: I need help in adding a student to the linked list and removing it by the name of the student. Also 
  if someone could explain the toString to me (my teacher told me to do it this way) that would be much appreciated.</p>
  
  <p>Student Class:</p>
  
  <pre><code> public class Student {
  private int studentID;
  private String fName;
  private String lName;
  private String Address;
  private String city;
  private String state;
  private String zip;
  private String major;
  
  
  public void Student(){
  
  }
  
  public void Student(int i, String f, String l, String a, String c, String s, String z, String m){
      studentID = i;
      fName = f;
      lName = l;
      Address = a;
      city = c;
      state = s;
      zip = z;
      major = m;
  }
  
  public int getStudentID(){
      return studentID;
  }
  public void setStudentID(int i){
      studentID = i;
  }
  public String getFName(){
      return fName;
  }
  public void setFName(String f){
      fName = f;
  }
  public String getLName(){
      return lName;
  }
  public void setLName(String l){
      lName = l;
  }
  public String getAddress(){
      return Address;
  }
  public void setAddress(String a){
      Address = a;
  }
  public String getCity(){
      return city;
  }
  public void setCity(String c){
      city = c;
  }
  public String getState(){
      return state;
  }
  public void setState(String s){
      state = s;
  }
  public String getZip(){
      return zip;
  }
  public void setZip(String z){
      zip = z;;
  }
  public String getMajor(){
      return major;
  }
  public void setMajor(String m){
      major = m;
  }
  
  }
  </code></pre>
  
  <p>Linked List Class: </p>
  
  <pre><code>public class LinkedList {
  
  private class Node{
      String value;
      Node next;
  
      Node (String val, Node n){
           value=val;
          next = n;
      }
  
      Node (String val)
      {
          this(val, null);
  
      }
  }
  private Node first;
  private Node last;
  
  public LinkedList(){
      first = null;
      last = null;
  }
  
  public boolean isEmpty(){
      return first== null;
  }
  
  public int size(){
      int count = 0;
      Node p = first;
      while (p !=null){
          count++;
          p = p.next;
      }
      return count;
  }
  
  public void add( String s){
      if (isEmpty())
      {
          first = new Node(s);
          last = first;
      }
      else 
      {
          last.next = new Node(s);
          last = last.next;
  
      }
  }
  
  public void  add(int index, String s){
      if (index &lt;0 || index &gt; size()){
          String message = String.valueOf(index);
          throw new IndexOutOfBoundsException(message);
      }
  
  
      if (index ==0){
          first = new Node(s, first);
          if (last == null)
              last = first;
          return;
      }
  
      Node pred = first;
      for (int k = 1; k &lt;= index -1; k++){
          pred = pred.next;
      }
      pred.next = new Node (s, pred.next);
  
      if (pred.next.next == null){
          last = pred.next;
      }
  }
  public String toString(){
  StringBuilder strBuilder = new StringBuilder();
  
  Node p = first;
  while (p != null){
      strBuilder.append(p.value+"\n");
      p = p.next;
  
      }
      return strBuilder.toString();
  }
  
  public String remove(int index){
      if (index &lt;0 || index &gt;=size()){
          String message = String.valueOf(index);
          throw new IndexOutOfBoundsException(message);
      }
  
      String element;
      if (index == 0){
          element = first.value;
          first = first.next;
          if (first == null){
              last = null;
          }
      }
      else 
      {
          Node pred = first;
          for (int k = 1; k &lt;=index -1; k++)
              pred = pred.next;
  
  
          element = pred.next.value;
          pred.next = pred.next.next;
          if (pred.next ==  null)
              last = pred;
  
      }
      return element;
  }
  
  
  
  
  }
  </code></pre>
  
  <p>Main (which is really bad so far):</p>
  
  <pre><code>import java.util.Scanner;
  public class StudentDemo {
  
  public static void main(String[] args) {
      Scanner key = new Scanner(System.in);
      LinkedList list = new LinkedList();
      menu();
      int input = key.nextInt();
  
          if (input == 1){
              if (input ==1){
                  System.out.println("Enter name");
                  String name = key.nextLine();
                  list.add(name);
  
                  System.out.println(list);
              }
          }
  
  
  
  }
  
  public static void menu(){
      System.out.println("Student Maintenence System:");
      System.out.println("1. Add Student");
      System.out.println("2. Remove Student");
      System.out.println("3. Print Student Information");
      System.out.println("4. Exit");
  }
  
  public static void optionOne(int input, LinkedList list, Scanner key){
      if (input ==1){
          System.out.println("Enter name");/*supposed to ask for a lot more but for the time being its only asking this*/
          String name = key.nextLine();
          list.add(name);
          list.toString();
  }
  }
  }
  </code></pre>