July 05, 2013

Convert temperature from C to F in Java

Write a Program in Java to Convert temperature from C to F 



TEMPERATURE(C to F)


import java.io.*;
class tem
{
public static void main(String args[])throws IOException
{
BufferedReader st=new BufferedReader(new InputStreamReader(System.in));
try
{
System.out.println("Enter the temperature in celcius: ");
double cel=Double.parseDouble(st.readLine());
double far=(cel*9)/5+32;
System.out.println("The Fahrenheit is "+far);
}
catch(Exception e){}
}
}



OUTPUT

C:\Program Files\Java\jdk1.5.0\bin>java tem

Enter the temperature in celcius:
75
The Fahrenheit is 167.0



No comments:
Write comments