Java – 编译错误 – 找不到符号 – 变量 Terminal

huangapple go评论73阅读模式
英文:

Java - compilation error - cannot find symbol - variable Terminal

问题

我刚开始学习Java。在编译以下代码时遇到了问题。

public class Conversion {
    public static void main(String[] args) {
        double euros;
        double dollars;
        System.out.println("欧元总数?");
        euros = Terminal.lireDouble();
        dollars = euros * 1.118;
        System.out.println("美元总数:");
        System.out.println(dollars);
    }
}

我得到了以下错误信息:

/Users/Mathieu/IdeaProjects/Conversion/src/com/company/Conversion.java:9:17
java: 找不到符号 符号: 变量 Terminal 位置:
类 com.company.Conversion

请问你能帮我吗?我的代码有什么问题吗?

提前谢谢你。

英文:

I have just started learning Java for first time.
I have an issue when compiling the following code.

public class Conversion {
public static void main (String[] args) {

    double euros;
    double dollars;
    System.out.println("Sum in euros? ");
    euros = Terminal.lireDouble();
    dollars = euros * 1.118;
    System.out.println("Sum in dollars: ");
    System.out.println(dollars);
}

}

I get the following error message:

> /Users/Mathieu/IdeaProjects/Conversion/src/com/company/Conversion.java:9:17
> java: cannot find symbol symbol: variable Terminal location:
> class com.company.Conversion

Please, could you help me ?
What is wrong with my code.

Thank you in advance

答案1

得分: 1

为了从用户获取输入,请使用以下代码:

import java.util.Scanner;

public class Conversion {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        double euros;
        double dollars;
        System.out.println("请输入欧元金额:");
        euros = in.nextDouble();
        dollars = euros * 1.118;
        System.out.println("美元金额为:");
        System.out.println(dollars);
    }
}

Scanner用于从用户获取输入。

英文:

In order to get input from the user use this

    import java.util.Scanner;
    public class Conversion {
    public static void main (String[] args) {
        Scanner in = new Scanner(System.in);
        double euros;
        double dollars;
        System.out.println("Sum in euros? ");
        euros = in.nextDouble();
        dollars = euros * 1.118;
        System.out.println("Sum in dollars: ");
        System.out.println(dollars);
    }
   }

Scanner is used to get input from the user

huangapple
  • 本文由 发表于 2020年10月17日 15:15:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/64399938.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定