为什么我的代码不识别符号而不是编译

问题描述 投票:0回答:1

我正在学习编程,但是我的代码有问题,但我不理解该错误。

“在此处输入图像描述”

请在下面查看我的代码

class Main {
  public static double calcAvg(double q1, double q2, double q3) {
    return (q1 + q2 + q3) / 3.0;
  }

  public static int ageInYears(int months) {
    return months / 12;
  }

  public static double convertCtoF(double C) {
    return (C * 9.0 / 5.0) + 32.0;
  }

  public static void main(String[] args) {
    Scanner in = new scanner (System.in);
    System.out.print("Enter employee ID: ");
    String empID = in.nextLine();

    System.out.print("Enter quiz 1 score: ");
    double quiz1 = in.nextDouble();
    in.nextLine();

    System.out.print("Enter quiz 2 score: ");
    double quiz2 = in.nextDouble();
    in.nextLine();

    System.out.print("Enter quiz 3 score: ");
    double quiz3 = in.nextDouble();
    in.nextLine();

    System.out.print("Enter age in months: ");
    int age = in.nextInt();
    in.nextLine();

    System.out.print("Enter temp in Celsius: ");
    double celsius = in.nextDouble();
    in.nextLine();

    System.out.printf("Employee ID: %s\n", empID);
    System.out.printf("Avg quiz score: %f\n", calcAvg(quiz1, quiz2, quiz3));
    System.out.printf("Age in years: %d\n", ageInYears(age));
    System.out.printf("Temp in Fahrenheit: %f\n", convertCtoF(celsius));
  }
}
java javac
1个回答
0
投票

在初始化时将导入添加到扫描仪,并且还要写入扫描仪而不是扫描仪

import java.util.Scanner;

public class Main {
    // ....
         Scanner sc = new Scanner(System.in);
}
© www.soinside.com 2019 - 2024. All rights reserved.