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

📄 scoresect.java

📁 学生成绩管理系统:能输入学科
💻 JAVA
字号:
package 学生考试成绩分析程序;import java.awt.*;import javax.swing.*;import java.awt.event.*;import java.io.*;import java.util.*;public class ScoreSect extends JFrame implements ActionListener{   static JLabel jlScoreSect,jlCount,jlPercentage;   static JLabel[] ScoreSect=new JLabel[5];   static JTextField[] jtCount=new JTextField[10];   static JButton jbExit;   static int[] count={0,0,0,0,0};   static int k=0,m=0,n=0,ccount=0;    static String[] line;    static String[] class1;    static String[] scourse;    static String[] score;    static double sc;      public ScoreSect(int[] count,int m){        JPanel jpanel1=new JPanel();        JPanel jpanel2=new JPanel();        jbExit=new JButton("退出");        jpanel1.setLayout(new GridLayout(0,3));        jlScoreSect=new JLabel("分数段");        jlCount=new JLabel("人数");        jlPercentage=new JLabel("百分比(%)");        ScoreSect[0]=new JLabel("   0--59   ");        ScoreSect[1]=new JLabel("   60--69  ");        ScoreSect[2]=new JLabel("   70--79  ");        ScoreSect[3]=new JLabel("   80--89  ");        ScoreSect[4]=new JLabel("   90--100 ");        jpanel2.add(jbExit);        jbExit.addActionListener(this);        jpanel1.add(jlScoreSect);        jpanel1.add(jlCount);        jpanel1.add(jlPercentage);                for(int i=0,j=0;j<5;i=i+2,j++)        {              String s= String.valueOf(count[j]) ;            String sp= String.valueOf((int)(count[j]*100*100/m)/100.0);            jtCount[i]=new JTextField(s);            jtCount[i+1]=new JTextField(sp);            jpanel1.add(ScoreSect[j]);            jpanel1.add(jtCount[i]);            jpanel1.add(jtCount[i+1]);        }         getContentPane().add(jpanel1,BorderLayout.CENTER);        getContentPane().add(jpanel2,BorderLayout.SOUTH);        this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);        this.setTitle("分数段分析");         this.pack();        this.setLocation(530,300);        this.setVisible(true);         k=0;m=0;n=0;ccount=0;         for(int i=0;i<5;i++)                  count[i]=0;    }   public ScoreSect(String Class,String course){      try{           BufferedReader input =new BufferedReader(new FileReader("G:\\Score\\score.txt"));          String L=input.readLine();     StringTokenizer tokenizer=new StringTokenizer(L,"*");     m=tokenizer.countTokens();     line=new String[m];     class1=new String[m/7];     scourse=new String[m/7];     score=new String[m/7];     for(int i=0;tokenizer.hasMoreTokens();i++)     {          line[i]=tokenizer.nextToken();     }    for(int j=0,h=1;j<m;j++,h++)                     {                         if(h==1){                             class1[n]=line[j];                             scourse[n]=line[j+1];                             score[n]=line[j+4];                             n++;                           }                         if(h==7){                             h=0;                         }                     }                   String s1,s2;          StringTokenizer scanner1=new StringTokenizer(Class);          StringTokenizer scanner2=new StringTokenizer(course);          s1=scanner1.nextToken();          s2=scanner2.nextToken();           for(int d=0;d<m/7;d++)          {               if((class1[d].equals(s1))&&(scourse[d].equals(s2)))              {               sc=Double.parseDouble(score[d]);               if(sc<=59&&sc>=0)                   count[0]++;               else if(sc<=69&&sc>=60)                   count[1]++;               else if(sc<=79&&sc>=70)                   count[2]++;               else if(sc<=89&&sc>=80)                   count[3]++;               else if(sc<=100&&sc>=90)                   count[4]++;               k++;           }            }           input.close();           new ScoreSect(count,k);               }      catch(Exception es){           k=0;m=0;n=0;ccount=0;           for(int i=0;i<5;i++)                  count[i]=0;          JOptionPane.showMessageDialog(null, "分析失败");      }   }      public void actionPerformed(ActionEvent e)    {        if(e.getSource()==jbExit)        {             this.setVisible(false);              k=0;m=0;n=0;ccount=0;              for(int i=0;i<5;i++)                  count[i]=0;                          }                       }}

⌨️ 快捷键说明

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