Friday, October 28, 2011

CALCULATOR AND CONVERTOR MOBILE APPLICATION

I had create a calculator and convertor "mobile" application(java platform). click here to download



//j2me coding for calculator and unit convertor
//by thaveethu
//to download application click here
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

//java mobile application calculator and convertor
//calculator application for java mobile
//unit convertor application for javaplatform
//j2me coding for convertor
//free download java calculator and unit convertor
//calculator mobile application free download
//free mobile application download
public class PocketCalc extends MIDlet implements CommandListener {

private boolean midletPaused = false;
public TextField t1,t2,t3,vt1,vt2,vt3;
int tha,tha1,tha2,tha3,tha4,tha5,tha6,tha7,tha8,tha9,th10;
ChoiceGroup len,len1,len2,len3,len4,len5;
public double fact(double d1)
{

double b=1;
for(int i=1;i<=d1;i++)
{
b=b*i;
}

return b;
}


private Form form;
private List list;
private Form form1;
private Form form2;
private Form form3;
private List list1;
private Form form4;
private Form form5;
private Form form6;
private Command backCommand;
private Command backCommand1;
private Command exitCommand;
private Command itemCommand1;
private Command itemCommand;
private Command itemCommand3;
private Command itemCommand2;
private Command backCommand2;
private Command itemCommand4;
private Command itemCommand5;
private Command itemCommand6;
private Command itemCommand7;
private Command backCommand3;
private Command itemCommand8;
private Command itemCommand9;
private Command itemCommand12;
private Command itemCommand10;
private Command itemCommand11;
private Command okCommand;
private Command okCommand1;
private Command okCommand2;
private Image image1;
private Image image4;
private Image image3;
private Image image2;
private Ticker ticker1;
private Image image6;
private Image image5;
private Image image7;
private Image image8;

public PocketCalc() {
}


private void initialize () {

}

public void startMIDlet () {

switchDisplayable (null, getList ());

}

public void resumeMIDlet () {

}

public void switchDisplayable (Alert alert, Displayable nextDisplayable) {

Display display = getDisplay ();
if (alert == null) {
display.setCurrent (nextDisplayable);
} else {
display.setCurrent (alert, nextDisplayable);
}

}



public void commandAction (Command command, Displayable displayable) {

if (displayable == form) {
if (command == backCommand) {

switchDisplayable (null, getList ());

} else if (command == itemCommand) {

double a=Double.parseDouble(t1.getString());
double b=Double.parseDouble(t2.getString());
double c=a+b;
String ss=Double.toString(c);

t3.setString(ss);
t1.setString(ss);
t2.setString("");


} else if (command == itemCommand1) {
double a=Double.parseDouble(t1.getString());
double b=Double.parseDouble(t2.getString());
double c=a-b;
String ss=Double.toString(c);

t3.setString(ss);
t1.setString(ss);
t2.setString("");


} else if (command == itemCommand10) {
double a=Double.parseDouble(t1.getString());
double c=a;
double b=Double.parseDouble(t2.getString());
double i=b;
if(i!=0)
{
for(;i>1;i--)
{
a=a*c;
}
}
t3.setString(""+a);


} else if (command == itemCommand11) {
double a=Double.parseDouble(t1.getString());
double b=Double.parseDouble(t2.getString());
double d3=fact(a);
double d4=fact(a-b);
double d5=d3/d4;
t3.setString(""+d5);


} else if (command == itemCommand12) {
double a=Double.parseDouble(t1.getString());
double b=Double.parseDouble(t2.getString());
double d3=fact(a);
double d4=fact(a-b);
double d5=fact(b);
double d6=d3/(d4*d5);
t3.setString(""+d6);


} else if (command == itemCommand2) {
double a=Double.parseDouble(t1.getString());
double b=Double.parseDouble(t2.getString());
double c=a*b;
String ss=Double.toString(c);

t3.setString(ss);
t1.setString(ss);
t2.setString("");


} else if (command == itemCommand3) {
double a=Double.parseDouble(t1.getString());
double b=Double.parseDouble(t2.getString());
double c=a/b;
String ss=Double.toString(c);

t3.setString(ss);
t1.setString(ss);
t2.setString("");


} else if (command == itemCommand4) {
t3.setString("");
t1.setString("");
t2.setString("");


} else if (command == itemCommand5) {
double a=Double.parseDouble(t1.getString());
double b=Double.parseDouble(t2.getString());
double c=a/b;
double d=c*100;
//String ss=Float.toString(d);
t3.setString(+d+"%");
switchDisplayable (null, getForm ());

} else if (command == itemCommand6) {
double a=Double.parseDouble(t1.getString());
double d1=Math.sin(a);
t3.setString(""+d1);


} else if (command == itemCommand7) {
double a=Double.parseDouble(t1.getString());
double d1=Math.cos(a);
t3.setString(""+d1);

} else if (command == itemCommand8) {
double a=Double.parseDouble(t1.getString());
double d1=Math.tan(a);
t3.setString(""+d1);


} else if (command == itemCommand9) {
double a=Double.parseDouble(t1.getString());
double b=fact(a);
t3.setString(""+b);


}
} else if (displayable == form1) {
if (command == backCommand) {

switchDisplayable (null, getList ());

}
} else if (displayable == form2) {
if (command == backCommand3) {

switchDisplayable (null, getList ());

}
} else if (displayable == form3) {
if (command == backCommand) {

switchDisplayable (null, getList ());

}
} else if (displayable == form4) {
if (command == backCommand) {

switchDisplayable (null, getList1 ());

} else if (command == okCommand) {


if((len.getSelectedIndex()==tha)&&(len1.getSelectedIndex()==tha))
{
double vs=Double.parseDouble(vt1.getString());
vt2.setString(""+vs);
}
else if((len.getSelectedIndex()==tha)&&(len1.getSelectedIndex()==tha1))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs/1000;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha)&&(len1.getSelectedIndex()==tha2))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*3.280839895;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha)&&(len1.getSelectedIndex()==tha3))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*100;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha)&&(len1.getSelectedIndex()==tha4))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs/1609.344 ;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha)&&(len1.getSelectedIndex()==tha5))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*39.37007874 ;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha)&&(len1.getSelectedIndex()==tha6))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*1.0936132983 ;
vt2.setString(""+vs1);
}
else
if((len.getSelectedIndex()==tha1)&&(len1.getSelectedIndex()==tha))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*1000;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha1)&&(len1.getSelectedIndex()==tha1))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha1)&&(len1.getSelectedIndex()==tha2))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*3280.839895 ;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha1)&&(len1.getSelectedIndex()==tha3))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*100000;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha1)&&(len1.getSelectedIndex()==tha4))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*0.62137119224 ;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha1)&&(len1.getSelectedIndex()==tha5))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*39370.07874 ;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha1)&&(len1.getSelectedIndex()==tha6))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*1093.6132983 ;
vt2.setString(""+vs1);
}
else
if((len.getSelectedIndex()==tha2)&&(len1.getSelectedIndex()==tha))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs/3.280839895 ;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha2)&&(len1.getSelectedIndex()==tha1))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*0.0003048;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha2)&&(len1.getSelectedIndex()==tha2))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha2)&&(len1.getSelectedIndex()==tha3))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*30.48 ;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha2)&&(len1.getSelectedIndex()==tha4))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*0.00018939393939;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha2)&&(len1.getSelectedIndex()==tha5))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*12 ;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha2)&&(len1.getSelectedIndex()==tha6))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*0.33333333333 ;
vt2.setString(""+vs1);
}
else
if((len.getSelectedIndex()==tha3)&&(len1.getSelectedIndex()==tha))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs/100;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha3)&&(len1.getSelectedIndex()==tha1))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs/100000;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha3)&&(len1.getSelectedIndex()==tha2))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*0.03280839895;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha3)&&(len1.getSelectedIndex()==tha3))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha3)&&(len1.getSelectedIndex()==tha4))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*0.0000062137119224 ;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha3)&&(len1.getSelectedIndex()==tha5))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*0.3937007874 ;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha3)&&(len1.getSelectedIndex()==tha6))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*0.010936132983;
vt2.setString(""+vs1);
}
else
if((len.getSelectedIndex()==tha4)&&(len1.getSelectedIndex()==tha))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*1609.344 ;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha4)&&(len1.getSelectedIndex()==tha1))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*1.609344;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha4)&&(len1.getSelectedIndex()==tha2))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*5280;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha4)&&(len1.getSelectedIndex()==tha3))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*160934.4;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha4)&&(len1.getSelectedIndex()==tha4))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha4)&&(len1.getSelectedIndex()==tha5))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*63360;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha4)&&(len1.getSelectedIndex()==tha6))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*1760;
vt2.setString(""+vs1);
}
else
if((len.getSelectedIndex()==tha5)&&(len1.getSelectedIndex()==tha))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*0.0254 ;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha5)&&(len1.getSelectedIndex()==tha1))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*0.0000254 ;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha5)&&(len1.getSelectedIndex()==tha2))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*0.083333333333 ;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha5)&&(len1.getSelectedIndex()==tha3))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*2.54;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha5)&&(len1.getSelectedIndex()==tha4))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*0.000015782828283 ;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha5)&&(len1.getSelectedIndex()==tha5))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha5)&&(len1.getSelectedIndex()==tha6))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*0.027777777778 ;
vt2.setString(""+vs1);
}
else
if((len.getSelectedIndex()==tha6)&&(len1.getSelectedIndex()==tha))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*0.9144 ;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha6)&&(len1.getSelectedIndex()==tha1))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*0.0009144 ;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha6)&&(len1.getSelectedIndex()==tha2))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*3 ;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha6)&&(len1.getSelectedIndex()==tha3))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*91.44;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha6)&&(len1.getSelectedIndex()==tha4))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*0.00056818181818 ;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha6)&&(len1.getSelectedIndex()==tha5))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*36;
vt2.setString(""+vs1);
}
else if((len.getSelectedIndex()==tha6)&&(len1.getSelectedIndex()==tha6))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs;
vt2.setString(""+vs1);
}

}
} else if (displayable == form5) {
if (command == backCommand) {

switchDisplayable (null, getList1 ());

} else if (command == okCommand1) {


if((len2.getSelectedIndex()==tha)&&(len3.getSelectedIndex()==tha))
{
double vs=Double.parseDouble(vt1.getString());
vt2.setString(""+vs);
}
else if((len2.getSelectedIndex()==tha)&&(len3.getSelectedIndex()==tha1))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*0.001;
vt2.setString(""+vs1);
}
else if((len2.getSelectedIndex()==tha)&&(len3.getSelectedIndex()==tha2))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*0.0022046226218;
vt2.setString(""+vs1);
}
else if((len2.getSelectedIndex()==tha)&&(len3.getSelectedIndex()==tha3))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs* 0.03527396195;
vt2.setString(""+vs1);
}
else if((len2.getSelectedIndex()==tha)&&(len3.getSelectedIndex()==tha4))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs/1000000;
vt2.setString(""+vs1);
}
else
if((len2.getSelectedIndex()==tha1)&&(len3.getSelectedIndex()==tha))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*1000;
vt2.setString(""+vs1);
}
else if((len2.getSelectedIndex()==tha1)&&(len3.getSelectedIndex()==tha1))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs;
vt2.setString(""+vs1);
}
else if((len2.getSelectedIndex()==tha1)&&(len3.getSelectedIndex()==tha2))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*2.2046226218 ;
vt2.setString(""+vs1);
}
else if((len2.getSelectedIndex()==tha1)&&(len3.getSelectedIndex()==tha3))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*35.27396195;
vt2.setString(""+vs1);
}
else if((len2.getSelectedIndex()==tha1)&&(len3.getSelectedIndex()==tha4))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*0.001;
vt2.setString(""+vs1);
}
else
if((len2.getSelectedIndex()==tha2)&&(len3.getSelectedIndex()==tha))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*453.59237;
vt2.setString(""+vs1);
}
else if((len2.getSelectedIndex()==tha2)&&(len3.getSelectedIndex()==tha1))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*0.45359237;
vt2.setString(""+vs1);
}
else if((len2.getSelectedIndex()==tha2)&&(len3.getSelectedIndex()==tha2))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs;
vt2.setString(""+vs1);
}
else if((len2.getSelectedIndex()==tha2)&&(len3.getSelectedIndex()==tha3))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*16;
vt2.setString(""+vs1);
}
else if((len2.getSelectedIndex()==tha2)&&(len3.getSelectedIndex()==tha4))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*0.00045359237;
vt2.setString(""+vs1);
}
else
if((len2.getSelectedIndex()==tha3)&&(len3.getSelectedIndex()==tha))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*28.349523125;
vt2.setString(""+vs1);
}
else if((len2.getSelectedIndex()==tha3)&&(len3.getSelectedIndex()==tha1))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*0.028349523125;
vt2.setString(""+vs1);
}
else if((len2.getSelectedIndex()==tha3)&&(len3.getSelectedIndex()==tha2))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*0.0625;
vt2.setString(""+vs1);
}
else if((len2.getSelectedIndex()==tha3)&&(len3.getSelectedIndex()==tha3))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs;
vt2.setString(""+vs1);
}
else if((len2.getSelectedIndex()==tha3)&&(len3.getSelectedIndex()==tha4))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*0.000028349523125;
vt2.setString(""+vs1);
}
else
if((len2.getSelectedIndex()==tha4)&&(len3.getSelectedIndex()==tha))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*1000000;
vt2.setString(""+vs1);
}
else if((len2.getSelectedIndex()==tha4)&&(len3.getSelectedIndex()==tha1))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*1000;
vt2.setString(""+vs1);
}
else if((len2.getSelectedIndex()==tha4)&&(len3.getSelectedIndex()==tha2))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*2204.6226218;
vt2.setString(""+vs1);
}
else if((len2.getSelectedIndex()==tha4)&&(len3.getSelectedIndex()==tha3))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs*35273.96195;
vt2.setString(""+vs1);
}
else if((len2.getSelectedIndex()==tha4)&&(len3.getSelectedIndex()==tha4))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs;
vt2.setString(""+vs1);
}
}
} else if (displayable == form6) {
if (command == backCommand) {

switchDisplayable (null, getList1 ());

} else if (command == okCommand2) {


if((len4.getSelectedIndex()==tha)&&(len5.getSelectedIndex()==tha))
{
double vs=Double.parseDouble(vt1.getString());
vt2.setString(""+vs);
}
else if((len4.getSelectedIndex()==tha)&&(len5.getSelectedIndex()==tha1))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=(vs*1.8)+32;
vt2.setString(""+vs1);
}
else if((len4.getSelectedIndex()==tha)&&(len5.getSelectedIndex()==tha2))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs+273.15;
vt2.setString(""+vs1);
}
else
if((len4.getSelectedIndex()==tha1)&&(len5.getSelectedIndex()==tha))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=(vs-32)/1.8;
vt2.setString(""+vs1);
}
else if((len4.getSelectedIndex()==tha1)&&(len5.getSelectedIndex()==tha1))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs;
vt2.setString(""+vs1);
}
else if((len4.getSelectedIndex()==tha1)&&(len5.getSelectedIndex()==tha2))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=((vs-32)/(1.8))+ 273.15;
vt2.setString(""+vs1);
}
else
if((len4.getSelectedIndex()==tha2)&&(len5.getSelectedIndex()==tha))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=(vs-273.15);
vt2.setString(""+vs1);
}
else if((len4.getSelectedIndex()==tha2)&&(len5.getSelectedIndex()==tha1))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=(vs*1.8)-459.67;
vt2.setString(""+vs1);
}
else if((len4.getSelectedIndex()==tha2)&&(len5.getSelectedIndex()==tha2))
{
double vs=Double.parseDouble(vt1.getString());
double vs1=vs;
vt2.setString(""+vs1);
}
}
} else if (displayable == list) {
if (command == List.SELECT_COMMAND) {

listAction ();

} else if (command == exitCommand) {

exitMIDlet ();

}
} else if (displayable == list1) {
if (command == List.SELECT_COMMAND) {

list1Action ();

} else if (command == backCommand) {

switchDisplayable (null, getList ());

}
}

}




public Form getForm () {
if (form == null) {

form = new Form ("ENTER INPUT");
form.addCommand (getBackCommand ());
form.addCommand (getItemCommand ());
form.addCommand (getItemCommand1 ());
form.addCommand (getItemCommand2 ());
form.addCommand (getItemCommand3 ());
form.addCommand (getItemCommand5 ());
form.addCommand (getItemCommand6 ());
form.addCommand (getItemCommand7 ());
form.addCommand (getItemCommand8 ());
form.addCommand (getItemCommand9 ());
form.addCommand (getItemCommand10 ());
form.addCommand (getItemCommand4 ());
form.addCommand (getItemCommand11 ());
form.addCommand (getItemCommand12 ());
form.setCommandListener (this);
t1=new TextField("ENTER FIRST INPUT","",20,TextField.DECIMAL);
t2=new TextField("ENTER SECOND INPUT","",20,TextField.DECIMAL);
t3=new TextField("RESULT","",20,TextField.ANY);
form.append(t1);
form.append(t2);
form.append(t3);

}
return form;
}

public Command getBackCommand () {
if (backCommand == null) {

backCommand = new Command ("Back", Command.BACK, 0);

}
return backCommand;
}

public List getList () {
if (list == null) {

list = new List ("WELCOME", Choice.IMPLICIT);
list.append ("CALCULATOR", getImage1 ());
list.append ("CONVERTOR", getImage5 ());
list.append ("HELP", getImage2 ());
list.append ("ABOUT", getImage3 ());
list.append ("EXIT", getImage4 ());
list.addCommand (getExitCommand ());
list.setCommandListener (this);
list.setFitPolicy (Choice.TEXT_WRAP_DEFAULT);
list.setSelectedFlags (new boolean[] { false, false, false, false, false });

}
return list;
}

public void listAction () {

String __selectedString = getList ().getString (getList ().getSelectedIndex ());
if (__selectedString != null) {
if (__selectedString.equals ("CALCULATOR")) {

switchDisplayable (null, getForm ());

} else if (__selectedString.equals ("CONVERTOR")) {

switchDisplayable (null, getList1 ());

} else if (__selectedString.equals ("HELP")) {

switchDisplayable (null, getForm1 ());

} else if (__selectedString.equals ("ABOUT")) {

switchDisplayable (null, getForm3 ());

} else if (__selectedString.equals ("EXIT")) {

exitMIDlet ();

}
}

}

public Command getBackCommand1 () {
if (backCommand1 == null) {

backCommand1 = new Command ("Back", Command.BACK, 0);

}
return backCommand1;
}

public Command getExitCommand () {
if (exitCommand == null) {

exitCommand = new Command ("Exit", Command.EXIT, 0);

}
return exitCommand;
}

public Command getItemCommand () {
if (itemCommand == null) {

itemCommand = new Command ("ADD", Command.ITEM, 0);

}
return itemCommand;
}

public Command getItemCommand1 () {
if (itemCommand1 == null) {

itemCommand1 = new Command ("SUBTRACTION", Command.ITEM, 0);

}
return itemCommand1;
}

public Command getItemCommand2 () {
if (itemCommand2 == null) {

itemCommand2 = new Command ("MULTIPLICATION", Command.ITEM, 0);

}
return itemCommand2;
}

public Command getItemCommand3 () {
if (itemCommand3 == null) {

itemCommand3 = new Command ("DIVISION", Command.ITEM, 0);

}
return itemCommand3;
}

public Command getBackCommand2 () {
if (backCommand2 == null) {

backCommand2 = new Command ("Back", Command.BACK, 0);

}
return backCommand2;
}

public Command getItemCommand4 () {
if (itemCommand4 == null) {

itemCommand4 = new Command ("CLEAR", Command.ITEM, 0);

}
return itemCommand4;
}

public Command getItemCommand5 () {
if (itemCommand5 == null) {

itemCommand5 = new Command ("PERCENTAGE", Command.ITEM, 0);

}
return itemCommand5;
}

public Image getImage1 () {
if (image1 == null) {

try {
image1 = Image.createImage ("/calculator.png");
} catch (java.io.IOException e) {
e.printStackTrace ();
}

}
return image1;
}

public Image getImage2 () {
if (image2 == null) {

try {
image2 = Image.createImage ("/exclamation.png");
} catch (java.io.IOException e) {
e.printStackTrace ();
}

}
return image2;
}

public Image getImage3 () {
if (image3 == null) {

try {
image3 = Image.createImage ("/eye.png");
} catch (java.io.IOException e) {
e.printStackTrace ();
}

}
return image3;
}

public Image getImage4 () {
if (image4 == null) {

try {
image4 = Image.createImage ("/asterisk_orange.png");
} catch (java.io.IOException e) {
e.printStackTrace ();
}

}
return image4;
}

public Form getForm1 () {
if (form1 == null) {

form1 = new Form ("HELP");
form1.addCommand (getBackCommand ());
form1.setCommandListener (this);
form1.append("CALCULATOR\n1.ENTER FIRST INPUT \n 2.ENTER SECOND INPUT \n 3.PRESS MORE AND CHOOSE OPERATION\n EX.if you want to find ncr, enter 'n' in first textfield. then enter 'r' value in second text field.then press MORE-> ncr\n CONVERTOR:\n1.choose the unit from \"FROM\" and \"TO\" choice group \nthen\n 2.ENTER INPUT\n and press \"CONVERT\"");
}
return form1;
}

public Form getForm2 () {
if (form2 == null) {

form2 = new Form ("form2");
form2.addCommand (getBackCommand3 ());
form2.setCommandListener (this);
form2.append("i am thaveethu....an engineering student\nGCE \n tirunelveli");
}
return form2;
}

public Command getBackCommand3 () {
if (backCommand3 == null) {

backCommand3 = new Command ("Back", Command.BACK, 0);

}
return backCommand3;
}

public Command getItemCommand6 () {
if (itemCommand6 == null) {

itemCommand6 = new Command ("sin", Command.ITEM, 0);

}
return itemCommand6;
}

public Command getItemCommand7 () {
if (itemCommand7 == null) {

itemCommand7 = new Command ("cos", Command.ITEM, 0);

}
return itemCommand7;
}

public Command getItemCommand8 () {
if (itemCommand8 == null) {

itemCommand8 = new Command ("tan", Command.ITEM, 0);

}
return itemCommand8;
}

public Command getItemCommand9 () {
if (itemCommand9 == null) {

itemCommand9 = new Command ("factorial", Command.ITEM, 0);

}
return itemCommand9;
}

public Form getForm3 () {
if (form3 == null) {

form3 = new Form ("ABOUT");
form3.setTicker (getTicker1 ());
form3.addCommand (getBackCommand ());
form3.setCommandListener (this);
form3.append("i am thaveethu\n computer science and engineering student of government college og engineering \n SEND YOUR SUGGESTION TO \n thaveethu1080@gmail.com BLOG:\n www.universalpctricks.blogspot.com \n website: \n www.thaveethupcm.appspot.com");
}
return form3;
}

public Ticker getTicker1 () {
if (ticker1 == null) {

ticker1 = new Ticker ("\thttp://facebook.com/thaveethu.gce");

}
return ticker1;
}

public Command getItemCommand10 () {
if (itemCommand10 == null) {

itemCommand10 = new Command ("power", Command.ITEM, 0);

}
return itemCommand10;
}

public Command getItemCommand11 () {
if (itemCommand11 == null) {

itemCommand11 = new Command ("npr", Command.ITEM, 0);

}
return itemCommand11;
}

public Command getItemCommand12 () {
if (itemCommand12 == null) {

itemCommand12 = new Command ("ncr", Command.ITEM, 0);

}
return itemCommand12;
}

public List getList1 () {
if (list1 == null) {

list1 = new List ("CONVERTORS", Choice.IMPLICIT);
list1.append ("LENGTH", getImage6 ());
list1.append ("WEIGHT", getImage8 ());
list1.append ("TEMPERATURE", getImage7 ());
list1.addCommand (getBackCommand ());
list1.setCommandListener (this);
list1.setSelectedFlags (new boolean[] { false, false, false });

}
return list1;
}

public void list1Action () {

String __selectedString = getList1 ().getString (getList1 ().getSelectedIndex ());
if (__selectedString != null) {
if (__selectedString.equals ("LENGTH")) {

switchDisplayable (null, getForm4 ());

} else if (__selectedString.equals ("WEIGHT")) {

switchDisplayable (null, getForm5 ());

} else if (__selectedString.equals ("TEMPERATURE")) {

switchDisplayable (null, getForm6 ());

}
}

}

public Form getForm4 () {
if (form4 == null) {

form4 = new Form ("LENGTH CONVERTOR");
form4.addCommand (getBackCommand ());
form4.addCommand (getOkCommand ());
form4.setCommandListener (this);
len = new ChoiceGroup ("FROM", Choice.POPUP);
tha=len.append("METER", null);
tha1=len.append("KM", null);
tha2= len.append("FEET",null);
tha3= len.append("CM",null);
tha4= len.append("MILE",null);
tha5= len.append("INCH",null);
tha6= len.append("YARD",null);

form4.append(len);
len1 = new ChoiceGroup ("TO", Choice.POPUP);
tha=len1.append("METER", null);
tha1=len1.append("KM", null);
tha2= len1.append("FEET",null);
tha3= len1.append("CM",null);
tha4= len1.append("MILE",null);
tha5= len1.append("INCH",null);
tha6= len1.append("YARD",null);

form4.append(len1);
vt1=new TextField("INPUT","",20,TextField.DECIMAL);
form4.append(vt1);
vt2=new TextField("OUTPUT","",20,TextField.DECIMAL);
form4.append(vt2);

}
return form4;
}

public Command getOkCommand () {
if (okCommand == null) {

okCommand = new Command ("CONVERT", Command.OK, 0);

}
return okCommand;
}

public Image getImage5 () {
if (image5 == null) {

try {
image5 = Image.createImage ("/compass.png");
} catch (java.io.IOException e) {
e.printStackTrace ();
}

}
return image5;
}

public Image getImage6 () {
if (image6 == null) {

try {
image6 = Image.createImage ("/sport_8ball.png");
} catch (java.io.IOException e) {
e.printStackTrace ();
}

}
return image6;
}

public Form getForm5 () {
if (form5 == null) {

form5 = new Form ("WEIGHT");
form5.addCommand (getBackCommand ());
form5.addCommand (getOkCommand1 ());
form5.setCommandListener (this);
len2= new ChoiceGroup ("FROM", Choice.POPUP);
tha=len2.append("GRAM", null);
tha1=len2.append("KILOGRAM", null);
tha2= len2.append("POUND",null);
tha3= len2.append("OUNCE",null);
tha4= len2.append("TON",null);


form5.append(len2);
len3 = new ChoiceGroup ("TO", Choice.POPUP);
tha=len3.append("GRAM", null);
tha1=len3.append("KILOGRAM", null);
tha2= len3.append("POUND",null);
tha3= len3.append("OUNCE",null);
tha4= len3.append("TON",null);
form5.append(len3);
vt1=new TextField("INPUT","",20,TextField.DECIMAL);
form5.append(vt1);
vt2=new TextField("OUTPUT","",20,TextField.DECIMAL);
form5.append(vt2);
}
return form5;
}

public Command getOkCommand1 () {
if (okCommand1 == null) {

okCommand1 = new Command ("CONVERT", Command.OK, 0);

}
return okCommand1;
}

public Form getForm6 () {
if (form6 == null) {

form6 = new Form ("TEMPERATURE");
form6.addCommand (getBackCommand ());
form6.addCommand (getOkCommand2 ());
form6.setCommandListener (this);
len4= new ChoiceGroup ("FROM", Choice.POPUP);
tha=len4.append("CELCIUS", null);
tha1=len4.append("FAHRENHEIT", null);
tha2= len4.append("KELVIN",null);
form6.append(len4);
len5 = new ChoiceGroup ("TO", Choice.POPUP);
tha=len5.append("CELCIUS", null);
tha1=len5.append("FAHRENHEIT", null);
tha2= len5.append("KELVIN",null);
form6.append(len5);
vt1=new TextField("INPUT","",20,TextField.DECIMAL);
form6.append(vt1);
vt2=new TextField("OUTPUT","",20,TextField.DECIMAL);
form6.append(vt2);
}
return form6;
}

public Command getOkCommand2 () {
if (okCommand2 == null) {

okCommand2 = new Command ("CONVERT", Command.OK, 0);

}
return okCommand2;
}

public Image getImage7 () {
if (image7 == null) {

try {
image7 = Image.createImage ("/rosette.png");
} catch (java.io.IOException e) {
e.printStackTrace ();
}

}
return image7;
}

public Image getImage8 () {
if (image8 == null) {

try {
image8 = Image.createImage ("/server.png");
} catch (java.io.IOException e) {
e.printStackTrace ();
}

}
return image8;
}

public void exitMIDlet() {
switchDisplayable(null, null);
destroyApp(true);
notifyDestroyed();
}

public void startApp() {
if (midletPaused) {
resumeMIDlet();
} else {
initialize();
startMIDlet();
}
midletPaused = false;
}


public void pauseApp() {
midletPaused = true;
}


public void destroyApp(boolean unconditional) {
}
}



click here to download

No comments:

Post a Comment