无法找到如何解决此错误,请帮助我。
import java.util.Scanner;
import java.io.*;
public class work {
public static void main(String[] args) throws IOException {
String Login;
int A,B,C,D,NumTea,NumStu,PerClass,Teacher,Total,LoginID,LoginType,Choice;
String[] Users = new String[20];
Scanner FileScan;
FileScan = new Scanner(new File("users.txt"));
A = 0;
while (FileScan.hasNext())
{
Users[A] = FileScan.nextLine(); //Find the function to fix this
A++;
}
Scanner reader = new Scanner(System.in);
// Ready to get database of students and teachers
// Arrays for seperating out students from teachers
String[] Teachers = new String[1000];
String[] Students = new String[1000];
Total = A;
System.out.println("Please wait for the system to intilize...");
B=0;
C=0;
//Ready to seperate students from teachers in for loops
for(B=0;B<=A;B++){
if(Users[B].substring(0,1) == "1"){ //Find String Cut Char Function
Students[C] = Users[B];
C=C+1;
}
}
NumStu = C+1;
C=0;
for(B=0;B<=A;B++){
if(Users[B].substring(0,1) == "2"){ //Find String Cut Char Function
Teachers[C] = Users[B];
C=C+1;
}
}
NumTea = C+1;
System.out.println("Each teacher has 1 class a day but each student has 2 classes per day");
System.out.println("There are " + NumTea + " teachers in the school therefore there are " + (NumTea) + " classes");
System.out.println("There are " + NumStu + " students in the school therefore there are " + ((NumStu*2)/NumTea) + " kids per class on average"); //Diving correctly?
PerClass = ((NumStu*2)/NumTea);
int[][] StudentClass = new int[NumStu][2]; //Looks at what classes each student has
int[][] TeacherClass = new int[NumTea][1000]; //Looks at what students each teacher has
for(B=0;B<=(NumStu-1);B++){
Teacher = (int)(Math.random()*NumTea); //Import Math Library and check random function
StudentClass[B][0] = Teacher; //Assigning first class
Teacher = (int)(Math.random()*NumTea);
StudentClass[B][1] = Teacher; //Assigning second class
if(StudentClass[B][0] == StudentClass[B][1]){ //Error checking for same class
Teacher = (int)(Math.random()*NumTea);
StudentClass[B][1] = Teacher;
}
}
//Ready to look at student classes and assign them to teachers
B=0;
C=0;
D=0;
int[] StuClass = new int[NumTea]; //Looks at how many students are in each class
for(B=0;B<=(NumTea-1);B++){
D=0;
for(C=0;C<=(NumStu-1);C++){
if(StudentClass[C][0] == B || StudentClass[C][1] == B){
TeacherClass[B][D] = C;
D=D+1;
}
}
StuClass[B] = D;
}
System.out.println("Classes print out:");
// Going to print out all students and all teachers in each class
A=0;
B=0;
for(A=0;A<=(NumTea-1);A++){
System.out.println(Teachers[A] + "'s class (" + (StuClass[A]+1) + "):");
for(B=0;B<=(StuClass[A]);B++){
System.out.println(" " + Students[(TeacherClass[A][B])]);
}
}
while(1==1){
System.out.println("Welcome to Wayzata WHS's SGS (Scheduling and Grading System)");
System.out.println("Login:");
Login = reader.nextLine();
A = 0;
LoginType = 0;
LoginID = 0;
for(A=0;A<=(NumStu-1);A++){
if(Students[A].toLowerCase() == Login.toLowerCase()){ //Check to see if string lower is correct
System.out.println("Found your account, linking you with the system...");
LoginID = A;
LoginType = 1;
}
}
for(A=0;A<=(NumTea-1);A++){
if(Teachers[A].toLowerCase() == Login.toLowerCase()){ //Check to see if string lower is correct
System.out.println("Found your account, linking you with the system...");
LoginID = A;
LoginType = 2;
}
}
//The user has typed in a name and the system has recognized it and found it in the system the program has logged ethier a student or teacher in
if(LoginType == 1){
System.out.println("Welcome " + Students[LoginID] + "! Signed in as: STUDENT");
System.out.println("What would you like to do today?");
System.out.println("1: See grades");
System.out.println("2: Logout");
Choice = reader.nextInt();
if(Choice == 1){
System.out.println("1: " + Teachers[(StudentClass[LoginID][0])] + "'s Class");
System.out.println("2: " + Teachers[(StudentClass[LoginID][1])] + "'s Class");
Choice = reader.nextInt();
//c.PrintClassGrades(LoginID,Choice); //Add a class for this
}
}else if(LoginType == 2){
System.out.println("Welcome " + Teachers[LoginID] + "! Signed in as: TEACHER");
System.out.println("What would you like to do today?");
System.out.println("1: Do attendance");
System.out.println("2: Look at class grades");
System.out.println("3: Add grade to gradebook");
System.out.println("4: Logout");
Choice = reader.nextInt();
if(Choice == 1){
//c.Attendance(LoginID); //Add a class for this
}else if(Choice == 2){
//c.ClassGrades(LoginID); //Add a class for this
}else if(Choice == 3){
//c.AddGrade(LoginID);//Add a class for this
}
}
}
}
}