import java.util.Scanner;
public class Temp
{
static double celsius;
static double fahrenheit;
public static void main (String[] args)
{
System.out.print("Please enter the temperature in degrees: ");
Scanner in = new Scanner(System.in);
double temp = in.nextDouble();
System.out.print("Enter F for Farhenheit or C for Celsius: ");
String type = in.next();
if(type.equalsIgnoreCase("c")){
celsius = (5.0/9.0) * fahrenheit - 32.0;
System.out.println(temp + " Farhenheit = " + celsius + " Celsius.");
}
if(type.equalsIgnoreCase("f")){
fahrenheit = (9.0/5.0) * celsius + 32.0;
System.out.println(temp + " Celsius = " + fahrenheit + " Farhenheit.");
}
}
}
This post has been edited by rbk3ai: 30 September 2012 - 02:55 PM

New Topic/Question
Reply




MultiQuote




|