java IO符号无法识别

时间:2016-03-13 23:41:21

标签: windows

所以我正在尝试学习Java并通过Sublime Text 2编写简单的代码,我在windows cmd提示符下编译并运行它(我已添加到我的路径以及Cygwin以获得Linux环境)。我已下载并将Java JDK JRE 1.8.0_73添加到我的路径中。

然而,当我编译我的代码时,我收到这样的错误:

CourseGrade.java:21: error: cannot find symbol
            IO.output("Enter your exam grade: ");
            ^
    symbol:   variable IO
    location: class CourseGrade  
CourseGrade.java:22: error: cannot find symbol
            examScore = IO.inputDouble();
                        ^
    symbol:   variable IO
    location: class CourseGrade
CourseGrade.java:24: error: cannot find symbol
            IO.output("Enter your lab grade: ");
            ^
    symbol:   variable IO
    location: class CourseGrade
CourseGrade.java:25: error: cannot find symbol
            labScore = IO.inputDouble();
                       ^
    symbol:   variable IO
    location: class CourseGrade
CourseGrade.java:27: error: cannot find symbol
            IO.output("Enter your homework grade: ");
            ^
    symbol:   variable IO
    location: class CourseGrade
CourseGrade.java:28: error: cannot find symbol
            hwScore = IO.inputDouble();
                      ^
    symbol:   variable IO
    location: class CourseGrade
CourseGrade.java:38: error: cannot find symbol
            IO.outputIn("Your final grade is " + finalGrade);
            ^
    symbol:   variable IO
    location: class CourseGrade
7 errors

----------------------------------------------------------------------------
Here is the java code I've written: 

public class CourseGrade
{
    public static void main(String[] args)
    {
        int examWeight = 70;    //Percentage weight given to examination
        int labWeight = 20;     //Percentage weight given to lab work
        int hwWeight = 10;      //Percentage weight given to homework

        double examScore;       //Exam score given to student
        double labScore;        //Lab score given to student
        double hwScore;         //Homework score given to student
        double finalGrade;      //Final grade obtained by student

        IO.output("Enter your exam grade: ");
        examScore = IO.inputDouble();

        IO.output("Enter your lab grade: ");
        labScore = IO.inputDouble();

        IO.output("Enter your homework grade: ");
        hwScore = IO.inputDouble();

        //Compute final grade as the weighted sum of exam, lab, and
        //and homework scores
        examScore = examScore + (examWeight / 100.0);
        labScore = labScore + (labWeight / 100.0);
        hwScore = hwScore + (hwWeight / 100.0);
        finalGrade = examScore + labScore + hwScore;

        //Output the final grade
        IO.outputIn("Your final grade is " + finalGrade);

我真的很感谢有人帮助解决这个问题

1 个答案:

答案 0 :(得分:0)

没有内置包或类称为“IO”(大写)。这听起来像是你写的(或从你的教授那里得到的)某些课程中的静态方法。

问:您是否获得了带有“IO”的.java源文件或.jar文件?如果是.jar文件,您是否已将其包含在CLASSPATH

中 问:你有import“IO”所属的包吗?根据您的示例代码,它看起来不像您导入任何 ...