I was creating a program that converts Farenheit to Celcius and vice versa. For some reason, the output is stuck on the first question. For my input, I typed in a double (6.99). I then clicked enter. When and after I type enter, the cursor moves downwards and it will keep on moving downwards until I type in a character or a string to then hit enter. How do I fix this? Here's my code:
import java.util.*;
//syntax for taking a number to the power is pow(base, exponent)
public class Main
{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("What is your temperature? ");
double temp1 = input.nextDouble();
input.nextDouble();
System.out.println("What degrees is that in?");
String degrees1 = input.nextLine();
if(degrees1.equals("Farenheit") || degrees1.equals("F") || degrees1.equals("farenheit"))
{
System.out.println("What do you want to convert to?");
String degrees2 = input.nextLine();
if(degrees2.equals("Celsius") || degrees2.equals("C") || degrees2.equals("celsius"))
{
double farenheitToCelsius = (5*(temp1 - 32))/9;
System.out.println(temp1 + " in ");
}
}
else
{
System.out.println("Invalid temperature");
}
}
}