What I've been trying to do:
-Ask for the temperature
-Ask what to convert to ("C", "c", "F", "f")
It compiles fine, but when it comes for the second question to be asked, I can't input anything, which doesn't allow me to move on. Any help? Thanks!
import java.util.Scanner;
public class TemperatureConversionSelection
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter a temperature in degrees (for example 29.6): ");
double temp;
temp = keyboard.nextInt();
System.out.println("Enter 'F' (or 'f') for Fahrenheit or 'C' (or 'c') for Celsius: ");
String letter;
letter = keyboard.nextLine();
if (letter == "F"){
double total = (9)*(temp)/(5) + (32);
System.out.println(temp + " degrees F = " + total + "degrees Celsius");}
if (letter == "f"){
double total = (9)*(temp)/(5) + (32);{
System.out.println(temp + " degrees F = " + total + "degrees Celsius");}
if (letter == "C"){
double total2 = (5)*(temp - 32)/(9);
System.out.println(temp + " degrees C = " + total + "degrees Fahrenheit");}
if (letter == "c"){
double total2 = (5)*(temp - 32)/(9);
System.out.println(temp + " degrees C = " + total + "degrees Fahrenheit");}
}
}
}