import java.io.*;
import java.util.*;
import javax.swing.*;
import javax.swing.table.*;
import java.awt.*;
import jxl.*; 
import jxl.write.*;
import jxl.format.*;

class data
{double x,y;
data(double xi,double yi)
{x=xi;y=yi;}
}

public class Ex2P6
{
     public static String toString(double x[],double y[]) 
     {   
     String s="";
     for(int i=0;i<x.length;i++)
     {s+="x["+i+"] = "+x[i]+" y["+i+"] = "+y[i]+"\n ";}
     return s;
     }
public static void main(String args[]) throws IOException,ClassCastException
{

try
{
String stringa1="xx";
ArrayList<data> b=new ArrayList<data>();
data d;
double xi=1;
double yi;
Workbook workbook = Workbook.getWorkbook(new File("data1.xls"));
Sheet sheet = workbook.getSheet(0); 
Cell cx;
Cell cy;
int i=0;
cx=sheet.getCell(1,i+1);
cy=sheet.getCell(2,i+1);
stringa1=cx.getContents();
try{
try{
while(!stringa1.equals(""))
{
NumberCell ncx =(NumberCell)cx; 
NumberCell ncy =(NumberCell)cy;
xi=ncx.getValue();
yi=ncy.getValue();
d=new data(xi,yi);
b.add(d);
i++; 
cx=sheet.getCell(1,i+1);
cy=sheet.getCell(2,i+1);
stringa1=cx.getContents();
}}catch(ArrayIndexOutOfBoundsException ai) {System.out.println("Array index out of bounds exception");};
} catch(ClassCastException bi) {System.out.println("class cast exception exception");};
double x[]=new double[b.size()];
double y[]=new double[b.size()];
int k=0;
     Iterator ii=b.iterator();
     while(ii.hasNext()) 
     {d=(data)ii.next();
	  Double ax=new Double(d.x);
	  Double ay=new Double(d.y);
      x[k]=ax.doubleValue();
      y[k]=ay.doubleValue();
      k++;
     }
JOptionPane.showMessageDialog(null,toString(x,y));
} 
  catch(jxl.read.biff.BiffException e1) {};
}

}