import java.util.*;
import java.lang.*;
import java.io.*;
import java.text.*;
import java.util.Locale;
import javax.swing.*;

 public class ELBA{ 
   public ELBA_DATA rd;

   public ELBA(int Tipi,int Hi)
   {if(!readELBA(Tipi,Hi) ) System.err.println("wrong name definition"); }
   
   
public String[][] toString(int L,double Toda,double Tsugir, double Tsucik)
{
	String b[][]=new String[10][3];
	double Tortalama=(Tsugir+Tsucik)/2.0;
	double dT=Tortalama-Toda;
	double Q;
	b[0][0]="Panel Radiator type ";
	b[1][0]="Panel Radiator height ";
	b[2][0]="Panel radiator length";
	b[3][0]="Room temperature";
	b[4][0]="Panel Radiator water inlet tempeature";
	b[5][0]="Panel Radiator water exit tempeature ";
	b[6][0]=" "+'\u0394'+ "T";
	b[7][0]="Heat capacity Q =";
	b[8][0]="Heat capacity Q =";
	b[9][0]="Heat capacity Q =";
	b[0][1]=""+rd.Tip;
	b[1][1]=""+rd.H;
	b[2][1]=""+L;
	b[3][1]=""+Toda;
	b[4][1]=""+Tsugir;
	b[5][1]=""+Tsucik;
	b[6][1]=""+dT;
	Q=rd.Q(L,Toda,Tsugir,Tsucik);
	b[7][1]=""+toString(Q,4,0);
	b[8][1]=""+toString(Q*0.8598041557,4,0);
    b[9][1]=""+toString(Q*3.41209588,4,0);
	b[1][2]=" mm";
	b[2][2]=" mm";
	b[3][2]=" degree Celcius";
	b[4][2]=" degree Celcius";
	b[5][2]=" degree Celcius";
	b[6][2]=" degree Celcius";
	b[7][2]=" W"; 
	b[8][2]=" kcal/h";
	b[9][2]=" BTU/h";   
	return b;	 
}
   public static String toString(double left, int w, int d)
   // converts a double to a string with given width and decimals.
   {
	NumberFormat df=NumberFormat.getInstance(Locale.US);
	df.setMaximumFractionDigits(d);
    df.setMinimumFractionDigits(d);
    df.setGroupingUsed(false);
    String s = df.format(left);
    while (s.length() < w)
      s = " " + s;
    if (s.length() > w)
    {
        s = "";
        for (int i=0; i<w; i++)
          s = s + "-";
    }
    return s;
    } 
            
public boolean readELBA(int Tipi,int Hi)
{
String s="";
Vector<ELBA_DATA> gi=new Vector<ELBA_DATA>();
rd=new ELBA_DATA(11,300,3.442737544,1.302);
try{gi.addElement(rd);} catch(ArrayIndexOutOfBoundsException e) 
   {System.out.println("Array Index Out Of Bounds Exception");}
rd=new ELBA_DATA(11,400,4.542272362,1.296);
try{gi.addElement(rd);} catch(ArrayIndexOutOfBoundsException e) 
   {System.out.println("Array Index Out Of Bounds Exception");}                                                                  
rd=new ELBA_DATA(11,500,5.656291339,1.289);
try{gi.addElement(rd);} catch(ArrayIndexOutOfBoundsException e) 
   {System.out.println("Array Index Out Of Bounds Exception");} 
rd=new ELBA_DATA(11,600,6.72267997,1.283);
try{gi.addElement(rd);} catch(ArrayIndexOutOfBoundsException e) 
   {System.out.println("Array Index Out Of Bounds Exception");}
rd=new ELBA_DATA(11,700,7.795927355,1.277);
try{gi.addElement(rd);} catch(ArrayIndexOutOfBoundsException e) 
   {System.out.println("Array Index Out Of Bounds Exception");}                                                                  
rd=new ELBA_DATA(11,800,8.909579846,1.27);
try{gi.addElement(rd);} catch(ArrayIndexOutOfBoundsException e) 
   {System.out.println("Array Index Out Of Bounds Exception");} 
rd=new ELBA_DATA(11,900,9.954262426,1.264);
try{gi.addElement(rd);} catch(ArrayIndexOutOfBoundsException e) 
   {System.out.println("Array Index Out Of Bounds Exception");} 
rd=new ELBA_DATA(21,300,4.29007117,1.33);
try{gi.addElement(rd);} catch(ArrayIndexOutOfBoundsException e) 
   {System.out.println("Array Index Out Of Bounds Exception");}
rd=new ELBA_DATA(21,400,5.674400207,1.321);
try{gi.addElement(rd);} catch(ArrayIndexOutOfBoundsException e) 
   {System.out.println("Array Index Out Of Bounds Exception");}                                                                  
rd=new ELBA_DATA(21,500,7.018700506,1.313);
try{gi.addElement(rd);} catch(ArrayIndexOutOfBoundsException e) 
   {System.out.println("Array Index Out Of Bounds Exception");} 
rd=new ELBA_DATA(21,600,8.38449779,1.304);
try{gi.addElement(rd);} catch(ArrayIndexOutOfBoundsException e) 
   {System.out.println("Array Index Out Of Bounds Exception");}
rd=new ELBA_DATA(21,700,9.725640632,1.295);
try{gi.addElement(rd);} catch(ArrayIndexOutOfBoundsException e) 
   {System.out.println("Array Index Out Of Bounds Exception");}                                                                  
rd=new ELBA_DATA(21,800,11.09333838,1.286);
try{gi.addElement(rd);} catch(ArrayIndexOutOfBoundsException e) 
   {System.out.println("Array Index Out Of Bounds Exception");} 
rd=new ELBA_DATA(21,900,12.42475922,1.277);
try{gi.addElement(rd);} catch(ArrayIndexOutOfBoundsException e) 
   {System.out.println("Array Index Out Of Bounds Exception");} 
rd=new ELBA_DATA(22,300,5.708583341,1.321);
try{gi.addElement(rd);} catch(ArrayIndexOutOfBoundsException e) 
   {System.out.println("Array Index Out Of Bounds Exception");}
rd=new ELBA_DATA(22,400,7.303746238,1.319);
try{gi.addElement(rd);} catch(ArrayIndexOutOfBoundsException e) 
   {System.out.println("Array Index Out Of Bounds Exception");}                                                                  
rd=new ELBA_DATA(22,500,8.836810488,1.317);
try{gi.addElement(rd);} catch(ArrayIndexOutOfBoundsException e) 
   {System.out.println("Array Index Out Of Bounds Exception");} 
rd=new ELBA_DATA(22,600,10.34101528,1.315);
try{gi.addElement(rd);} catch(ArrayIndexOutOfBoundsException e) 
   {System.out.println("Array Index Out Of Bounds Exception");}
rd=new ELBA_DATA(22,700,11.79776542,1.313);
try{gi.addElement(rd);} catch(ArrayIndexOutOfBoundsException e) 
   {System.out.println("Array Index Out Of Bounds Exception");}                                                                  
rd=new ELBA_DATA(22,800,13.17181264,1.312);
try{gi.addElement(rd);} catch(ArrayIndexOutOfBoundsException e) 
   {System.out.println("Array Index Out Of Bounds Exception");} 
rd=new ELBA_DATA(22,900,14.57782074,1.31);
try{gi.addElement(rd);} catch(ArrayIndexOutOfBoundsException e) 
   {System.out.println("Array Index Out Of Bounds Exception");} 
rd=new ELBA_DATA(33,300,8.000870659,1.329);
try{gi.addElement(rd);} catch(ArrayIndexOutOfBoundsException e) 
   {System.out.println("Array Index Out Of Bounds Exception");}
rd=new ELBA_DATA(33,400,9.988664611,1.329);
try{gi.addElement(rd);} catch(ArrayIndexOutOfBoundsException e) 
   {System.out.println("Array Index Out Of Bounds Exception");}                                                                  
rd=new ELBA_DATA(33,500,11.81419599,1.33);
try{gi.addElement(rd);} catch(ArrayIndexOutOfBoundsException e) 
   {System.out.println("Array Index Out Of Bounds Exception");} 
rd=new ELBA_DATA(33,600,13.61272583,1.33);
try{gi.addElement(rd);} catch(ArrayIndexOutOfBoundsException e) 
   {System.out.println("Array Index Out Of Bounds Exception");}
rd=new ELBA_DATA(33,700,15.28534085,1.331);
try{gi.addElement(rd);} catch(ArrayIndexOutOfBoundsException e) 
   {System.out.println("Array Index Out Of Bounds Exception");}                                                                  
rd=new ELBA_DATA(33,800,16.92892589,1.331);
try{gi.addElement(rd);} catch(ArrayIndexOutOfBoundsException e) 
   {System.out.println("Array Index Out Of Bounds Exception");} 
rd=new ELBA_DATA(33,900,18.57251092,1.331);
try{gi.addElement(rd);} catch(ArrayIndexOutOfBoundsException e) 
   {System.out.println("Array Index Out Of Bounds Exception");} 
int i;
Enumeration n1=gi.elements();
while(n1.hasMoreElements())
{
   rd=(ELBA_DATA)n1.nextElement();
   if (rd.Tip==Tipi && rd.H==Hi) {return true;}
}
System.out.println(" required ELBA_DATA Radiator type "+Tipi+" Height  "+Hi+" can not be located");
return false;
}


}
