title: Scanning from file with seperate classes, scanner starts over when going between classes
body: <p>my code:
  Student class...</p>
  
  <pre><code> import java.io.File;
   import java.io.FileNotFoundException;
   import java.util.Scanner;
  
   public class Student {
      private Scanner scanner;
  
      //initialize data members
      private String firstName;
      private String lastName;
      private int assignmentScore;
      private int labScore;
      private int quizScore;
      private int attendanceScore;
      private int homeworkScore;
      private int midterm1Score;
      private int midterm2Score;
      private int finalExamScore;
      private int zyanteScore;
      private int patScore;
      private int testScore;
      private String letterGrade;
  
      public void setScanner() {
          try { //start try statement
              scanner = new Scanner(new File("gradesA5.txt")); //initialize scanner to scan from the grades.txt file
          } //end try statement
          catch (FileNotFoundException e) { //start catch statement
              System.out.println("Error opening file. Please make sure t  that you have a grades.txt file in the same folder as GradeCalculator.class"); //print statement telling user that the grades.txt file is not in the right place
              System.exit(0); //system exit 
          } //end catch statement
      }
  
      public Scanner getScanner(){
          return scanner;
      }
  
      public void setfirstName(){
          if(scanner.hasNext()){
              firstName = scanner.next();
          }
      }
  
      public String getFirstName(){
          return firstName;
      }
  
      public void setLastName(){
          if(scanner.hasNext()){
              lastName = scanner.next();
          }   
      }
  
      public String getLastName(){
          return lastName;
      }
  
      public void setAssignmentScore(){
          assignmentScore = 0;
          int i = 0;
          int[] assignment = new int[6];
  
          while(scanner.hasNext() &amp;&amp; i &lt;= 5){
              assignment[i] = scanner.nextInt();
              assignmentScore += assignment[i];
              i++;
          } 
      }
  
      public int getAssignmentScore(){
          return assignmentScore;
      }
  
      public void setLabScore(){
          labScore = 0;
          int i = 0;
          int[] lab = new int[15];
  
          while(scanner.hasNext() &amp;&amp; i &lt;=14){
              lab[i] = scanner.nextInt();
              labScore += lab[i];
              i++;
          }
      }
  
      public int getLabScore(){
          return labScore;
      }
  
      public void setQuizScore(){
          if(scanner.hasNext()){
              quizScore = scanner.nextInt();
          }
      }
  
      public int getQuizScore(){
          return quizScore;
      }
  
      public void setAttendanceScore(){
          if(scanner.hasNext()){
              attendanceScore = scanner.nextInt();
          }
      }
  
      public int getAttendanceScore(){
          return attendanceScore;
      }
  
      public int computeTotalHomeworkScore(){
          homeworkScore = (assignmentScore + labScore + attendanceScore);
          return homeworkScore;
      }
  
      public void setMidterm1Score(){
          if(scanner.hasNext()){
              midterm1Score = scanner.nextInt();
          }
      }
  
      public int getMidterm1Score(){
          return midterm1Score;
      }
  
      public void setMidterm2Score(){
          if(scanner.hasNext()){
              midterm2Score = scanner.nextInt();
          }
      }
  
      public int getMidterm2Score(){
          return midterm2Score;
      }
  
      public void setFinalExamScore(){
          if(scanner.hasNext()){
              finalExamScore = scanner.nextInt();
          }
      }
  
      public int getFinalExamScore(){
          return finalExamScore;
      }
  
      public void setZyanteScore(){
          if(scanner.hasNext()){
              zyanteScore = scanner.nextInt();
          }
      }
  
      public int getZyanteScore(){
          return zyanteScore;
      }
  
      public void setPATScore(){
          if(scanner.hasNext()){
              patScore = scanner.nextInt();
          }
      }
  
      public int getPATScore(){
          return patScore;
      }
  
      public int computeTotalTestScore(){
          testScore = (midterm1Score + midterm2Score + finalExamScore + quizScore + zyanteScore + patScore);
          return testScore;
      }
  
      public void computeLetterGrade(){
          if ((testScore &lt;165 &amp;&amp; homeworkScore &lt;780) || (testScore &lt;180 &amp;&amp; homeworkScore &lt;720) || (testScore &lt;195 &amp;&amp; homeworkScore &lt;660) || (testScore &lt;210 &amp;&amp; homeworkScore &lt;660) || (homeworkScore &lt;600)){ //if statement that executes if scores earned a failing grade
              letterGrade = "P" ; //sets letterGrade string to P
          } //end if statement
  
          if (((testScore &gt;= 150 &amp;&amp; testScore &lt;= 164) &amp;&amp; (homeworkScore &gt;= 780)) || ((testScore &gt;= 165 &amp;&amp; testScore &lt;= 179) &amp;&amp; (homeworkScore &gt;=720)) || ((testScore &gt;=180 &amp;&amp; testScore &lt;=194) &amp;&amp; (homeworkScore &gt;= 660 &amp;&amp; homeworkScore &lt;= 1139)) || 
              ((testScore &gt;= 195 &amp;&amp; testScore &lt;= 209) &amp;&amp; (homeworkScore &gt;= 660 &amp;&amp; homeworkScore &lt;= 1079)) || ((testScore &gt;= 210 &amp;&amp; testScore &lt;= 224) &amp;&amp; (homeworkScore&gt;= 600 &amp;&amp; homeworkScore &lt;= 959)) || ((testScore &gt;= 225 &amp;&amp; testScore &lt;= 239) &amp;&amp; (homeworkScore &gt;= 600 &amp;&amp; homeworkScore &lt;= 899)) ||
              ((testScore &gt;= 240 &amp;&amp; testScore &lt;= 254) &amp;&amp; (homeworkScore &gt;= 600 &amp;&amp; homeworkScore &lt;= 839)) || ((testScore &gt;= 255 &amp;&amp; testScore &lt;= 269) &amp;&amp; (homeworkScore &gt;= 600 &amp;&amp; homeworkScore &lt;= 779)) || ((testScore &gt;= 270 &amp;&amp; testScore &lt;= 284) &amp;&amp; (homeworkScore &gt;= 600 &amp;&amp; homeworkScore &lt;= 779)) ||
              ((testScore &gt;= 285 &amp;&amp; testScore &lt;= 300) &amp;&amp; (homeworkScore &gt;= 600 &amp;&amp; homeworkScore &lt;= 719))) { //if statement that executes if scores earned an average grade
              letterGrade = "A" ; //sets letterGrade string to A
          } //end if statement
  
          if (((testScore &gt;= 180 &amp;&amp; testScore &lt;= 194) &amp;&amp; (homeworkScore &gt;=  1140 &amp;&amp; homeworkScore &lt;= 1200)) || ((testScore &gt;= 195 &amp;&amp; testScore &lt;= 209) &amp;&amp; (homeworkScore &gt;= 1080 &amp;&amp; homeworkScore &lt;= 1200)) ||
              ((testScore &gt;= 210 &amp;&amp; testScore &lt;= 224) &amp;&amp; (homeworkScore &gt;= 960 &amp;&amp; homeworkScore &lt;= 1200)) || ((testScore &gt;= 225 &amp;&amp; testScore &lt;= 239) &amp;&amp; (homeworkScore &gt;= 900 &amp;&amp; homeworkScore &lt;= 1200)) ||
              ((testScore &gt;= 240 &amp;&amp; testScore &lt;= 254) &amp;&amp; (homeworkScore &gt;= 840 &amp;&amp; homeworkScore &lt;= 1200)) || ((testScore &gt;= 255 &amp;&amp; testScore &lt;= 269) &amp;&amp; (homeworkScore &gt;= 780 &amp;&amp; homeworkScore &lt;= 1200)) ||
              ((testScore &gt;= 270 &amp;&amp; testScore &lt;= 284) &amp;&amp; (homeworkScore &gt;= 780 &amp;&amp; homeworkScore &lt;= 1200)) || ((testScore &gt;= 285 &amp;&amp; testScore &lt;= 300) &amp;&amp; (homeworkScore &gt;= 720 &amp;&amp; homeworkScore &lt;= 1200))) { //if statement that executes if scores earned a good grade
              letterGrade = "G" ; //sets letterGrade string to G
          } //end if statement
      }
  
      public String getLetterGrade(){
          return letterGrade;
      }
  
      public void testing() {
          for (int i = 0; i &lt; 7; i++) {
              if (scanner.hasNext()) {
                  String test = scanner.next();
              }
          }
      }
   }      
  </code></pre>
  
  <p>CourseOffering class...</p>
  
  <pre><code> import java.io.File;
   import java.io.FileNotFoundException;
   import java.util.Scanner;
  
   public class CourseOffering {
  private Scanner scanner;
  
  Student myStudent = new Student();
  
  //initialize data members
  private int students;
  private String description;
  private int allTotalHomeworkScore = 0;
  private int allTotalTestScore = 0;
  private int totalStudents = 0;
  private int numberOfSemesters;
  private int studentArrayCount = 0;
  private double homeworkAverage;
  private double testAverage;
  
  public CourseOffering(Scanner inScanner){
      scanner = inScanner;
  }
  
  public void setNumberOfSemesters(){
      if(scanner.hasNext()){
          numberOfSemesters = scanner.nextInt();
      }
  }
  
  public int getNumberOfSemesters(){
      return numberOfSemesters;
  }
  
  public void setStudents(){
      int[] student = new int[numberOfSemesters];
      student[studentArrayCount] = scanner.nextInt();
      students = student[studentArrayCount];
      studentArrayCount++;
      totalStudents += students;
  }
  
  public double computeHomeworkAverage(){
      allTotalHomeworkScore += myStudent.computeTotalHomeworkScore();
      homeworkAverage = (allTotalHomeworkScore / totalStudents);
      return homeworkAverage;
  }
  
  public double computeTestAverage(){
      allTotalTestScore += myStudent.computeTotalTestScore();
      testAverage = (allTotalTestScore / totalStudents);
      return testAverage;
  }
  
  public void countPassingStudents(){
  
  }
   }
  </code></pre>
  
  <p>CourseStatistics class (the one that calls the others)...</p>
  
  <pre><code> import java.io.File;
   import java.io.FileNotFoundException;
   import java.util.Scanner;
  
   public class CourseStatistics {
  
  public static void main(String[] args) {
  
      Scanner scanner = null;
  
      try { //start try statement
          scanner = new Scanner(new File("gradesA5.txt")); //initialize scanner to scan from the grades.txt file
      } //end try statement
      catch (FileNotFoundException e) { //start catch statement
          System.out.println("Error opening file. Please make sure that you have a grades.txt file in the same folder as GradeCalculator.class"); //print statement telling user that the grades.txt file is not in the right place
          System.exit(0); //system exit 
      } //end catch statement
  
      Student myStudent = new Student();
      CourseOffering myCourse = new CourseOffering(scanner);
      myStudent.setScanner();
      myStudent.getScanner();
      myStudent.testing();
      myCourse.setNumberOfSemesters();
      for(int i = 0; i &lt; 4; i++){
      myStudent.setfirstName();
      myStudent.setLastName();
      myStudent.setAssignmentScore();
      myStudent.setLabScore();
      myStudent.setMidterm1Score();
      myStudent.setMidterm2Score();
      myStudent.setFinalExamScore();
      myStudent.setQuizScore();
      myStudent.setAttendanceScore();
      myStudent.setPATScore();
      myStudent.setZyanteScore();
      myStudent.computeLetterGrade();
      System.out.println(myStudent.getFirstName() + " " + myStudent.getLastName() + " " + myStudent.computeTotalHomeworkScore() + " " + myStudent.computeTotalTestScore() + " " + myStudent.getLetterGrade());
      }
      System.out.println(myCourse.getNumberOfSemesters());
  }   
   }
  </code></pre>
  
  <p>Output is...</p>
  
  <pre><code>Anthony Hopkins 854 284 P
  John Smith 730 214 G
  Pan Mei 730 267 A
  Rafael Vega 801 236 A
  3
  </code></pre>
  
  <p>The data object in the .txt file is 3, and even though the <code>myCourse.setNumberOfSemesters()</code> isn't the first thing to scan, it still scans to that first data of 3. How do i get the two scanning classes to mix, meaning one continues off where the other left off.</p>