⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 querycourse.java

📁 简易的学生课程成绩系统
💻 JAVA
字号:
import java.util.*;
import java.io.*;
import java.lang.*;
public class QueryCourse
{
     public static void main(String args[])
    {
    try{
          System.out.println("Please input the course name to query or input 'stop' to end query");
          BufferedReader readfile = new BufferedReader(new FileReader("database.csv"));
          BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
          String course = input.readLine();
          course=course.trim();
          CourseInf records;
          String line;
          int total;
          int average;
         while(!(course.equals("stop")))
         {
             records = new CourseInf(course);
            while((line = readfile.readLine())!=null)
            {
               String [] s = line.trim().split(",");
               Integer i;
               i = new Integer(s[2]) ;
               CompareString q=new CompareString();
               boolean flag=q.compare(course,s[1]);
               if(flag==true)
               {
                  Course newcourse;
                  newcourse= new Course(s[0],i);
                  records.addRecord(newcourse);
                }       
           }
          total = records.getTotalScore();
          if(!(records.getSize()==0))
          {
          records.showStudentList();
          average = total / records.getSize();
          System.out.print("The number of students is: ");
          System.out.println(records.getSize());
          System.out.print("The average score is: ");
          System.out.println(average);
          }
          else
            System.out.println("This course has no record");
          System.out.println("Please input the course name to query or input 'stop' to end query");
          input = new BufferedReader(new InputStreamReader(System.in));
          course = input.readLine();
          course.trim();
        }
        readfile.close();
    }
         catch(FileNotFoundException e)
    {
       System.out.println("File not found");
    }
    catch(IOException e)
    {
       System.out.println("IO Exception");    
      }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -