Monday, August 15, 2011

CelsiusToFahrenheit

import java.util.*;
class CelsiusToFahrenheit
{

public static void main(String[] args)
{

System.out.println("Enter a temperature in Celsius: ");
Scanner s = new Scanner(System.in);
double Fahr = 0;

if (s.hasNextDouble())
{
Fahr = (s.nextDouble()*9) / 5 + 32;
}
System.out.println("The temperature in Fahrenheit is: " + Fahr);
}
}





output

enter a temp in celcius
12
the temp in fahrnhet is
53.6






No comments:

Post a Comment