import java.io.*;
import javax.swing.*;
import javax.tools.*;
import java.util.*;

class HT_BConv_external
 {
  ref_CS rd;
  double Csf,n;
  
  public HT_BConv_external(String ref,double Csfi,double ni)
  {rd=new ref_CS(ref);
   Csf=Csfi;n=ni;
  }
  public HT_BConv_external(String ref)
  {rd=new ref_CS(ref);
   surface_selector();
  }
  public void surface_selector()
  {
  Object s[]={"Water-copper scored",
              "Water-copper polished",
              "Water-stainless steel chemically etched",
              "Water-stainless steel mechanically polished",
              "Water-stainless steel ground and polished",
              "Water-brass",
              "water-nickel",
              "Water-platinium",
              "n-pentane-polished copper",
              "n-pentane-lapped copper",
              "Benzene-chromium",
              "Ethyl alcohol-chromium",
              "Carbontetrachloride-polished copper"
               };
  double cs[]={0.0068,0.0128,0.0133,0.0132,0.0080,0.0060,0.006,0.013,0.0154,0.0049,0.0101,0.0027,0.007};
  double nn[]={1,1,1,1,1,1,1,1,1.7,1.7,1.7,1.7,1.7};	  
  ImageIcon picture=new ImageIcon("avustralya_orman.jpg");
  String name=(String)JOptionPane.showInputDialog(null,"select liquid metal couple: ",
    "surface coefficient",JOptionPane.QUESTION_MESSAGE,picture,s,"Water-copper polished");
  int j=0;
  for(int i=0;i<s.length;i++)
  {if(name.equals(s[i])) {j=i;break;}}
  Csf=cs[j];
  n=nn[j];
  }
  
  public double h(double ts,double tbl)
  { //
	double a[]=rd.property(tbl);
    //for referance 
    double rol=a[8];
    double rov=a[9];
    double mul=a[16];
    double Cpl=a[20]*1e3;
    double sigma=a[24];
    double hfg=a[12]*1e3;
    double dt=ts-tbl;
    double Prl=a[25];
    double x=Cpl*dt/Csf/hfg/Math.pow(Prl,n);
    double h=mul*hfg/ dt*Math.sqrt(9.806*(rol-rov)/sigma)*(x*x*x);
    return h;
  }
  
  public static void main(String args[])
  {
  double t=112;//C
  double tw=100;//C
  HT_BConv_external kk=new HT_BConv_external("water");
  double h1=kk.h(t,tw);
  System.out.println("h="+h1);
  double A=0.04;//m^2
  double q1=h1*(t-tw);
  double Q=(t-tw)*h1*A;//
String s1="JTable örneği";
String s[]={"property","value","unit","referance"};
 JTableP pp=new JTableP(kk.rd.toString(t),s);
JOptionPane.showMessageDialog(null,pp,s1,JOptionPane.PLAIN_MESSAGE);
  System.out.println("Q="+Q+"Watt/m^2"+"q1="+q1);
  }
 }