如何修复Java中非法的表达式开始错误?

如何修复Java中非法的表达式开始错误?,java,Java,我发现错误: 表达式开始非法,否则不带if和语句开始非法 代码如下: import java.util.Scanner; public class Temperature_Converter { public static void main(String[] args) { System.out.println("Welcome!This program takes temperature as an input and an input" +

我发现错误:

表达式开始非法,否则不带if和语句开始非法

代码如下:

import java.util.Scanner;

public class Temperature_Converter {
    public static void main(String[] args) {
        System.out.println("Welcome!This program takes temperature as an input and an input" +
                " indicating wether we're converting from Celsius to Fahrenheit or Fahrenheit to Celsius");

        Scanner scan = new Scanner (System.in);

                System.out.println("Please enter \"C\" if we\'re converting from Fahrenheit");

        System.out.println("Please enter \"F\" if we're converting from Celsius");

        String temp_key = scan.nextLine();

        System.out.println("Please enter the numerical value of the temperature");

        double temp_value = scan.nextDouble();

        if (temp_key.equals("F"));
        {
            {
                double result = temp_value - 32 / 1.8;

                System.out.println("When converting " + temp_value + "Fahrenheit to Celsius,\n" +

                        " the result is " + result);
            }
             else if (temp_key.equals("C")
        }

             double result = temp_value * 1.8 + 32;

             System.out.println("When converting " + temp_value + "From Celsius to Fahrenheit,\n + ");
                                "the result is;"+ result;);

    }
    static {;
    System.out.println("Next time make sure you enter either F or C");
    }
}

丢失分号和双嵌套大括号块

这:

应该是:

    if (temp_key.equals("F"))
    {
        double result = temp_value - 32 / 1.8;
当我在这里的时候

本声明:

double result = temp_value - 32 / 1.8;
不会像你认为的那样从F转换成C。首先计算32/1.8。(就像你在九年级时学的代数一样)。你想说:

double result = (temp_value - 32) / 1.8;

通过缩进代码,这将使结构明显错误。你的IDE只用一个键盘快捷键就可以做到这一点。事实上,我认为在这里帮助他并不好。他应该自己解决那些问题。
double result = (temp_value - 32) / 1.8;