Hi,
I am trying to do a calculator for celcius to farenheit and viceversa. However I cannot understand why my program does not work. After reading the scanner it does anything and I really do not know why. Could anybody give me a hand here is what i have gotten (please be nice I am new to Java :D).
import java.util.*;
public class Main {
/**
* @param args
*/
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
System.out.println("Choose F for farneheit to celsius, C for Celsius to farenheit:");
String option = keyboard.next();
if (option == "F" || option == "f")
{
System.out.println("Enter a farenheit Degree:");
int number = keyboard.nextInt();
double farenheit = number;
double celsius = (5.0/9) * (farenheit - 32);
System.out.println(number + "In Farenheit degrees is" + celsius + "in celsius degree");
}
else if (option == "C" || option == "c")
{
System.out.println("Enter a celcius Degree:");
int number = keyboard.nextInt();
double celcius = number;
double farenheit = (celcius * 1.8) + 32;
System.out.println(number + "In Celsius degrees is" + farenheit + "in farenheit degree");
}
else {
System.out.println("Please select correct parameters");
}
}
}