Sunday, January 13, 2013


 ♥♥♥ Temperature Converter In Java ♥♥♥


import javax.swing.*;
class temp{

public static void main(String args[]){
String name;
do{
String a=JOptionPane.showInputDialog(null,"Converter List.."+"\n"+"=================="+"\n"+"1:Temperture"+"\n"+"2:Weight"+"\n"+"3:Length"+"\n"+ "4:Volume"+"\n"+"5:Mass"+"\n"+"Select Any One:");
int sel=Integer.parseInt(a);



if(sel==1)
{

String t=JOptionPane.showInputDialog(null,"Temperature"+"\n"+"=============="+"\n"+"1:Fahrenheit to celcius"+"\n"+"2:Farhite To Kalvin"+"\n"+"3:Celsis To Kalvin"+"\n"+"Selcet Any Converter:");

int c=Integer.parseInt(t);
if(c==1){
String cel=JOptionPane.showInputDialog("Enter Fahrenheit value :");
int f=Integer.parseInt(cel);
float res=((f-32)*5/9);
JOptionPane.showMessageDialog(null,"Celsis value is:"+res);

}//celcis
if(c==2){
String cel=JOptionPane.showInputDialog("Enter Farhenhite value :");
int f=Integer.parseInt(cel);
double res=(f + 459.67) * 5 / 9;
JOptionPane.showMessageDialog(null,"Kalvin value is:"+res);

}//farhin
if(c==3){
String cel=JOptionPane.showInputDialog("Enter celcius value :");
int f=Integer.parseInt(cel);
float res=(f+273);
JOptionPane.showMessageDialog(null,"The Kalvin value:"+res);
}//kalvin

}//tem

if(sel==2)
{

String w=JOptionPane.showInputDialog(null,"Weigth"+"\n"+"==============="+"\n"+"1:Pound To Killo"+"\n"+"2:Carat To Gram"+"\n"+"3:Ounce To Grame"+"\n"+"Selcet Any Converter:");
 int c=Integer.parseInt(w);

if(c==1){
String pound=JOptionPane.showInputDialog(null,"Enter the pound value");
int k=Integer.parseInt(pound);
float rest=k*0.45359237f;
JOptionPane.showMessageDialog(null,"The kilo value is "+rest);
}
 if(c==2){
 String carat=JOptionPane.showInputDialog(null,"Enter the Carat value");
 int ca=Integer.parseInt(carat);
float r=ca*0.2f;
JOptionPane.showMessageDialog(null,"The Gram value is "+r);

 }

 if(c==3){
 String ounce=JOptionPane.showInputDialog(null,"Enter the Ounce value");
 int gr=Integer.parseInt(ounce);
 float re=gr*28.3495f;
JOptionPane.showMessageDialog(null,"The Gram value is "+re);
 }

}//weight
if(sel==3)
{

String w=JOptionPane.showInputDialog(null,"Length"+"\n"+"==============="+"\n"+"1:Mile To km"+"\n"+"2:Foot to Meter"+"\n"+"3:Inch to Cm"+"\n"+"Selcet Any Converter:");
 int c=Integer.parseInt(w);
 if(c==1){
 String mile=JOptionPane.showInputDialog(null,"Enter the mile value");
 int km=Integer.parseInt(mile);
 float rs=km*1.60934f;
 JOptionPane.showMessageDialog(null,"The Km value is " +rs);

 }
 if(c==2){
 String foot=JOptionPane.showInputDialog(null,"Enter the foot value");
 int meter=Integer.parseInt(foot);
 float rst=meter*0.3048f;
 JOptionPane.showMessageDialog(null,"The meter value is " +rst);
 }

 if(c==3){
  String inch=JOptionPane.showInputDialog(null,"Enter the Inch value");
 int cm=Integer.parseInt(inch);
 float rst=cm*2.54f;
 JOptionPane.showMessageDialog(null,"The centimeter value is " +rst);

 }

}//length

if(sel==4)
{

String w=JOptionPane.showInputDialog(null,"Volume"+"\n"+"==============="+"\n"+"1:Litre to Millilitre"+"\n"+"2:Cubic foot  to Cubic Meter"+"\n"+"3:Cubic Inch to Imperial oz"+"\n"+"Selcet Any Converter:");
 int c=Integer.parseInt(w);
 if(c==1){
 String litre=JOptionPane.showInputDialog(null,"Enter the Litre Value");
 int ml=Integer.parseInt(litre);
 float rt=ml*1000f;
 JOptionPane.showMessageDialog(null,"The Millilitre value is " +rt);
 }
 if(c==2){
 String cf=JOptionPane.showInputDialog(null,"Enter the Cubic Foot value");
 int cm=Integer.parseInt(cf);
 float srt=cm*0.0283168f;
 JOptionPane.showMessageDialog(null,"The Cubic meter is " +srt);

 }

 if(c==3){
 String ci=JOptionPane.showInputDialog(null,"Enter the Cubic Inch value");
 int imoz=Integer.parseInt(ci);
 float st=imoz*0.576744f;
 JOptionPane.showMessageDialog(null,"The Imperial oz is " +st);

 }

}//Volume

if(sel==5)
{

String w=JOptionPane.showInputDialog(null,"Mass" + "\n"+"===============" + "\n" + "1:Long ton To short ton" + "\n" +"2:Gram to kilogram" + "\n" + "3:Stone  To Ounce"+"\n" +"Selcet Any Converter:");
 int c=Integer.parseInt(w);
 if(c==1){
 String lgton=JOptionPane.showInputDialog(null,"Enter the long ton value");
 float shton=Float.parseFloat(lgton);
 float res=shton*1.12f;
 JOptionPane.showMessageDialog(null,"Short ton value is "+res);
 }
 if(c==2){

 String gram=JOptionPane.showInputDialog(null,"Enter the Gram value");
 float kgm=Float.parseFloat(gram);
 float trs=kgm*0.001f;
 JOptionPane.showMessageDialog(null,"Kilogram value is "+trs);

 }

 if(c==3){
 String stone=JOptionPane.showInputDialog(null,"Enter the Stone value");
 float oun=Float.parseFloat(stone);
 float ret=oun*224f;
 JOptionPane.showMessageDialog(null,"The ounce value is "+ret);

 }

 if(c==4){        

 String asd=JOptionPane.showInputDialog(null,"Enter US_Dollor");
 float p=Float.parseFloat(asd);
  int rup=94;
 float res=(rup*p);
 JOptionPane.showMessageDialog(null,"paskistan Rupee:"+res);

 }
}//Mass



name=JOptionPane.showInputDialog(null,"Do you want to Continue Yes or No:");

}while(name.equals("YES")||name.equals("yes"));
JOptionPane.showMessageDialog(null,"Thanku For Using the Converter...");
}


}

OUTPUT :\




No comments: