猿问

找到符号 readline 时出错,找不到包

代码,无法理解为什么我们有错误一切看起来都很好。请帮忙


import java.io.*;

public class ReadKeyboard3

{

    public static void main(String[] args) throws IOException

    {

        Scanner scanner = new Scanner(System.in);

        BufferedReader in = new BufferedReader(isr);


        System.out.print("Enter marks for English: ");

        String EnglishMarks = scanner.readline();

        int English = Integer.parseInt(EnglishMarks);


        System.out.print("Enter marks for Maths: ");

        String MathsMarks = in.readLine();

        int Maths = Integer.parseInt(MathsMarks);


        System.out.print("Enter marks for Science: ");

        String ScienceMarks = in.readLine();

        int Science = Integer.parseInt(ScienceMarks);


        float avg = (English + Maths + Science)/3;

        system.out.println("Average of all 3 subjects:" +avg);

    }

}

错误:


ReadKeyboard3.java:10: error: cannot find symbol

        String EnglishMarks = in.readline();

                                ^

  symbol:   method readline()

  location: variable in of type BufferedReader

ReadKeyboard3.java:22: error: package system does not exist

        system.out.println("Average of all 3 subjects:" +avg);

谁能帮助我理解错误


杨魅力
浏览 243回答 1
1回答

牛魔王的故事

您尝试调用的实际函数是readLine()(not readline())。同样在第 22 行,使用System而不是system(因为 Java 区分大小写,如注释中所述)此外,对于 using Scanner,您需要导入java.util.Scanner.
随时随地看视频慕课网APP

相关分类

Java
我要回答