import java.io.*;
class std {
  int i;
  String n;
  double s;
}
public class ByteDataInputTest {
  public static void main(String[] args) {    
    File ifile = new File("c:\\ByteScore.txt");
    FileInputStream f_in = null;
    BufferedInputStream b_in = null;
    DataInputStream d_in = null;
    System.out.println("Read Data from File : \n" + ifile);
    System.out.println("===========================");
    boolean eof=false; double sum=0; int c=0;
    std[] x = new std[50];
    try {
      f_in = new FileInputStream(ifile);
      b_in = new BufferedInputStream(f_in);
      d_in = new DataInputStream(b_in);
      while (!eof) {
        x[c] = new std();
        x[c].i = d_in.readInt();
        x[c].n = d_in.readUTF();
        x[c].s = d_in.readDouble();
        sum = sum+x[c].s;
        c++;
      }
    }
    catch (EOFException e){
      eof = true;
    }
    catch (IOException e){
      System.out.println(e);
    }
    finally {
      try {
        if (d_in != null)
          d_in.close();
        double avg =sum/c;        
        for (int i=0;i<c;i++)
          System.out.printf("%-10d%-10s%-6.2f\n",x[i].i,x[i].n,x[i].s);
        System.out.println("===========================");
        System.out.printf("mean = %.2f\n",avg);
        System.out.println("===========================");
      }
      catch (IOException e){
        System.out.println(e);
      }
    }
  }
}