[php]
import java.util.Scanner;
public class Temperature
{
public static void main(String args[])
{
Scanner input=new Scanner(System.in);
double Celsius=0,Fahrenheit=0,tempValue=0;
int choice=0;
System.out.print("+===========================+\n");
System.out.print("| [1] Convert to Fahrenheit |\n");
System.out.print("| [2] Convert to Celsius |\n");
System.out.print("+===========================+\n");
System.out.print("+->");
choice=input.nextInt();
switch(choice)
{
case 1:
System.out.print("Enter Celsius: ");
Celsius=input.nextDouble();
tempValue=(Celsius+32)*(0.55555555555555555555555555555556);
System.out.printf("Fahrenheit = %.2f",tempValue);
break;
case 2:
System.out.print("Enter Fahrenheit: ");
Fahrenheit=input.nextDouble();
tempValue=(Fahrenheit-32)*(1.8);
System.out.printf("Celsius = %.2f",tempValue);
break;
default:
System.out.println("Invalid Input... Try Again.");
break;
}
}
}
[/php]
Maybe you can explain to me why i convert from Celsius to Fahrenheit.. get 2 numbers try to reverse and get different numbers... i messed up
