不行了,我开始发晕了。package csdn.applet;import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class applet3 extends WindowAdapter
        implements ActionListener
{
   int i=0;
   String str="";   Frame f;
   Button b1,b2,b3;
   TextArea ta,tb;
   FileDialog fd1;//寻找/打开文件对话框
   Font fo=new Font("",1,18);
   TextField t[]=new TextField[15];
   Panel p[]=new Panel[15];   public static void main(String args[])
   {
      applet3 that=new applet3();
      that.go();
   }
   public void go()
   {
      f=new Frame("金融班(200072)");//applet窗口标题
      b1=new Button("打开");//打开分数表按钮
      b2=new Button("分数统计");//分析/统计分数按钮
      b3=new Button("退出");
      ta=new TextArea("",0,0,3);
      tb=new TextArea("",0,0,3);
      fd1=new FileDialog(f,"打开",0);
       Font fo=new Font("Dialog",Font.BOLD,18);
       ta.setFont(fo);
      Panel p1=new Panel();
      Panel p2=new Panel();
      Panel p3=new Panel();
      Panel p4=new Panel();
      Panel p5=new Panel();
      f.setLayout(new GridLayout(1,3));
      f.add(p1);
      f.add(p2);
      f.add(p3);
      p1.setLayout(new BorderLayout());
      p1.add(b1,"North");
      p1.add(ta,"Center");
      p2.setLayout(new GridLayout(16,1));
      p2.add(new Label("分数"));
      for(i=0;i<15;i++)//添加15个文本域
      {
         p[i]=new Panel();
         t[i]=new TextField(3);
         p2.add(t[i]);
      }
      p3.setLayout(new BorderLayout());
      p3.add(b2,"North");
      p3.add(tb,"Center");      f.setBounds(100,100,370,300);
      f.setBackground(Color.green);
      f.addWindowListener(this);
      f.setVisible(true);       b1.addActionListener(this);
       b2.addActionListener(this);
       b3.addActionListener(this);
   }
   public void windowClosing(WindowEvent e)
   {
      System.exit(0);
   }
   public void actionPerformed(ActionEvent e)
   {
      int a1=0,a2=0,a4=0,a5=0,a3=0,a6=0;//学员分数分为6个等级
      if(e.getSource()==b1)
      {
          fd1.setVisible(true);
          int b;
          File f1=new File(fd1.getDirectory(),fd1.getFile());//从文件选择对话框中得到文件
          int a=(int)f1.length();//文件长度
          byte buffer[]=new byte[a];//文件内容缓存
          try
          {
              FileInputStream rf=new FileInputStream(f1);//创建文件输入通道
              b=rf.read(buffer,0,a);//读取文件内容
              str=new String(buffer,0,b,"GB2312");//转换文件内容成GB2312内码
          }
          catch(IOException f)
          {
              str="文件读取错误";
          }
          ta.setText(str);
      }
      //创建保存15个分数变量(因为分析/统计的分数从applet的文本中取得)
      String s1="",s2="",s3="",s4="",s5="",s6="",s7="",s8="",s9="",s10="",
      s11="",s12="",s13="",s14="",s15="";
      //创建保存15个分数
      double    t1=0,t2=0,t3=0,t4=0,t5=0,t6=0,t7=0,t8=0,t9=0,t10=0,
                 t11=0,t12=0,t13=0,t14=0,t15=0,temp=0;
      int i=0,j=0;
      s1=t[0].getText();     s2=t[1].getText();
      s3=t[2].getText();     s4=t[3].getText();
      s5=t[4].getText();     s6=t[5].getText();
      s7=t[6].getText();     s8=t[7].getText();
      s9=t[8].getText();     s10=t[9].getText();
      s11=t[10].getText();     s12=t[11].getText();
      s13=t[12].getText();     s14=t[13].getText();
      s15=t[14].getText();
      try {//转换类型:从字符类型转换成双精度类型
          t1 = Double.parseDouble(s1);
          t2 = Double.parseDouble(s2);
          t3 = Double.parseDouble(s3);
          t4 = Double.parseDouble(s4);
          t5 = Double.parseDouble(s5);
          t6 = Double.parseDouble(s6);
          t7 = Double.parseDouble(s7);
          t8 = Double.parseDouble(s8);
          t9 = Double.parseDouble(s9);
          t10 = Double.parseDouble(s10);
          t11 = Double.parseDouble(s11);
          t12 = Double.parseDouble(s12);
          t13 = Double.parseDouble(s13);
          t14 = Double.parseDouble(s14);
          t15 = Double.parseDouble(s15);
          //转换类型结束
    }
    catch(Exception ex)
    {//如果类型转换出现异常则不进行分析/统计操作
        JOptionPane.showMessageDialog(f,"十五个文本框必须填满,并且都必须输入数字!");
       return;
    }
    double f[]={t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13,t14,t15};
    for(i=0;i<15;i++)//冒泡排序,从高到低排列
    {
        for(j=i;j<15;j++)
        {
            if(f[i]<f[j])//比较如果f[]中i位置后面的分数比i位置分数高则调换两者的位置
            {
            temp=f[i];//冒泡排序中间器:暂时保存i位置分数
            f[i]=f[j];//把i位置后边分数高的值赋给i位置
            f[j]=temp;//
        }
        }
    }
    for(i=0;i<15;i++)
    {
        if(f[i]<49)
            a1++;//累计分数小于49的学员数
        if(f[i]>=50&&f[i]<59)
            a2++;//累计分数大于等于50小于59的学员数
        if(f[i]>=60&&f[i]<69)
            a3++;//累计分数大于等于60小于69的学员数
        if(f[i]>=70&&f[i]<79)
            a4++;//累计分数大于等于70小于79的学员数
        if(f[i]>=80&&f[i]<89)
            a5++;//累计分数大于等于80小于89的学员数
        if(f[i]>=90)
            a6++;//累计分数大于等于90的学员数
    }    if(e.getSource()==b2)
    {
        java.text.DecimalFormat df=new java.text.DecimalFormat("#.##");
        String s="名次-----分数 \n";
        double scoreCount=0;
        for(int ii=0;ii<f.length;ii++) {
            scoreCount+=f[ii];//统计15位学员分数总数
            s+=" "+(ii+1)+" ----- "+f[ii]+"\n";//按分数大小显示
        }
        s+="-------------\n分数统计:\n";
        s+="总分:"+scoreCount;
        s+="\n平均分:"+df.format(scoreCount/15);
        s+="\n-------------\n分数段统计:\n";
        s+="49分以下: "+a1+" 人\n";
        s+="50~~59分: "+a2+" 人\n";
        s+="60~~69分: "+a3+" 人\n";
        s+="70~~79分: "+a4+" 人\n";
        s+="80~~89分: "+a5+" 人\n";
        s+="90分以上: "+a6+" 人\n";
        this.tb.setText(s);
    }
   }
}