I tried using break; it gave me an error and without break; it gives me an error saying that unreachable statement ...Can anyone help?
import java.util.Scanner;
/**
Convert a temperature in degrees from either celsius to
fahrenheit or fahrenheit to celsius.
*/
public class TempConverter
{
static Scanner console = new Scanner(System.in);
public static void main (String[] args)
{
double farenheitTemp,celsiusTemp;
while (true) {
System.out.printf("Enter a temperture in degree Farenheit:");
farenheitTemp = console.nextDouble();
celsiusTemp = (farenheitTemp *5.0/9.0) +32;
System.out.printf("Celsius Temperature: " + celsiusTemp);
System.out.printf("Enter a temperature in degree Celsius:");
celsiusTemp = console.nextDouble();
farenheitTemp = (celsiusTemp * 9.0/5.0) - 32;
System.out.printf("FarenheitTemp:" + farenheitTemp);
}
if(farenheitTemp == -40) {
System.out.printf("Quit ");
}
}
}
Edited by ZekeDragon, 03 April 2010 - 02:30 PM.
Please use [code] tags (the # button) when posting code.


Sign In
Create Account


Back to top









