View Single Post
Old Jun 9th, 2005, 9:21 AM   #6
HeX
Programmer
 
HeX's Avatar
 
Join Date: May 2005
Location: Kosova
Posts: 94
Rep Power: 4 HeX is on a distinguished road
Send a message via MSN to HeX
are you allowed to use JOptionPane ? if yes then:

import java.util.*;

public class TempConversion
{
    public static void main(String[] args)
    {
	double result;
	String degree;
	int input;
    	
	degree = JOptionPane.showInputDialog("Enter: \n C - Fahrenheit to Celsius\n F - Celsius to Fahrenheit");


	input = new Integer(JOptionPane.showInputDialog("Enter the degree:")).intValue();

	if(degree == "C" || degree == "c")
	{
			result = 5.0/9.0 * (input - 32);
			System.out.println(input + " Fahrenheit is " + result + " Celsius");
	}
	else if(degree == "F" || degree == "f")
	{
		result = 9.0/5.0 * input + 32;
		System.out.println(input + " Celsius is " + result + " Fahrenheit");
	}
	
    }
}
__________________
countdown++;
HeX is offline   Reply With Quote