import javax.swing.*;
import java.awt.Graphics;
import java.io.*;
import java.util.*;

public class alfa extends JApplet
{
    //girdi dosyasi :
    // mikronK - emisivite(dalga boyu)
    // IR datalari 20 C (293 K i‡in de§erlendirildi)
    static double s1=0;
    static double s2=0;
    double elt1;
    
    public static double F(double slt)
    {
      //siyah cisim yuzdesi
      // slt mikrometre*K
      double s=14387.69/slt;
      double toplam=0;
      if(slt==0) return 0;
      for(int n=1;n<200;n++)
      {
      toplam+=Math.exp(-n*s)/n*(s*s*s+3.0*s*s/n+6.0*s/(n*n)+6.0/(n*n*n));
      }
      toplam*=15/(Math.PI*Math.PI*Math.PI*Math.PI);
      return toplam;
    }

    public static double F(double slt1, double slt2)
    {
     return (F(slt2)-F(slt1));
    }

    public static double eT(String dosya) throws IOException
    {  
       File myfile = new File(dosya);
       BufferedReader b= new BufferedReader(new FileReader(myfile));     
       boolean EOF=false;
       double sl1=Text.readDouble(b);;
       double Fl1=Text.readDouble(b);;
       s1=sl1;
       double sl2=0;
       double Fl2=0;
       double Toplam=0;
       while (!EOF)
       {
       try{
       sl2=Text.readDouble(b);
       s2=sl2;
       Fl2=Text.readDouble(b);
       Toplam+=(Fl1+Fl2)/2.0*F(sl1,sl2);
       sl1=sl2;
       Fl1=Fl2;
       } catch (EOFException e) {b.close();EOF=true;}
       } //while
       return Toplam;
    }

    public static double BBEP(double T)
    {
      return 5.67051e-8*T*T*T*T;
    }

    public void init()
    {
     s1=0;
     s2=0;
     String s;
     //="IR1.txt";
     s=JOptionPane.showInputDialog("Dosya adi : ");
     double elt=0;
     try{
     elt=eT(s);
     } catch (IOException e) {}
     elt1=elt/F(s1,s2);
    }

    public void paint(Graphics g)
    {
         g.drawRect(15,10,470,20);
         g.drawString("emmisivite("+s1+" - "+s2+") = "+elt1,25,25);
    }
}
