View Single Post
Old Feb 15th, 2006, 8:20 PM   #31
Kilo
Expert Programmer
 
Kilo's Avatar
 
Join Date: Nov 2005
Location: In Pink Clam?
Posts: 542
Rep Power: 0 Kilo is an unknown quantity at this point
Send a message via AIM to Kilo
[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
__________________
"When in Rome, Do as the Romans Do"
"Beauty is in the eye of the BEER holder"
"Save your breath your going to need it for your blow up doll later"

SearchLores.org
Kilo is offline   Reply With Quote