Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/382.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 我一直收到一个错误,说找不到符号变量键盘_Java - Fatal编程技术网

Java 我一直收到一个错误,说找不到符号变量键盘

Java 我一直收到一个错误,说找不到符号变量键盘,java,Java,我的double distancel=keyboard.nextdouble()一直出现错误我是java新手,正在使用一个名为bluej的程序。我不明白为什么它说键盘需要是一个变量。如果你们能帮我解决这个错误,那就太好了。我总是喜欢学习。谢谢 您试图引用一个未声明的变量,这就是编译器说他找不到键盘的原因 只需将所有键盘参考替换为输入 似乎是打字错误或复制粘贴错误。您的扫描仪被称为输入,而不是键盘您在这里调用时应该更改它,例如: double distance=键盘.nextdouble()将其更

我的
double distancel=keyboard.nextdouble()一直出现错误我是java新手,正在使用一个名为bluej的程序。我不明白为什么它说键盘需要是一个变量。如果你们能帮我解决这个错误,那就太好了。我总是喜欢学习。谢谢

您试图引用一个未声明的变量,这就是编译器说他找不到
键盘的原因

只需将所有
键盘
参考替换为
输入


似乎是打字错误或复制粘贴错误。

您的
扫描仪
被称为
输入
,而不是
键盘
您在这里调用时应该更改它,例如:
double distance=键盘.nextdouble()将其更改为
double distancel=input.nextdouble()

我还看到了另一件事:

totalKilos=总英里*英里*千克

您没有任何声明的变量
totalKilos
来分配此值

你应该
inttotalkilos=totalMiles*miles*kilos

这里也是一样:
distance1+distance2+distance2+distance4=总英寸


我想你想做
double totalInches=distance1+distance2+distance2+distance4

就像您声明了输入扫描变量并对其进行了初始化一样,您需要在使用它之前声明键盘变量并对其进行初始化,以便Java了解您在使用“键盘”变量时的确切含义
键盘从何而来?看来你的<代码>扫描器被称为“代码>输入< /代码>。请考虑将这个问题作为回答。还有更多的观点。。f、 e.“int totalMiles=10%”和println调用。但解决所有问题并不明智,因为他正在努力学习Java。
  import javax.swing.JOptionPane;
  import java.io.File;
  import java.util.Scanner;
  public class Map{
  public static void main(String[] args){ 

  // create a Scanner object 
  Scanner input = new Scanner(System.in);

 //Prompt the user to enter three numbers in inches 
 System.out.print("enter four numbers:");
 double distance1 = input.nextDouble();
 double distance2 = input.nextDouble();
 double distance3 = input.nextDouble();
double distance4 = input.nextDouble();

 //public classify DistanceScale

    //Make a constant to hold kilometers to miles conversion
    //final const MILESTOKILOS = 1.609344;

    // Explain the program to the user
    System.out.println("Welcome! This program calculates true distance from map measurements You can enter up to 4 distances");
    System.out.println();

    // ask user for 4 distances, from the map.
    System.out.print("Enter distance 1 (in inches): ");
    double distancel = keyboard.nextdouble();

    System.out.print("Enter distance 2 (in inches): "); 
    double distance2 = keyboard.nextdouble();        

    System.out.print = "Enter distance 2 (in inches): ";
    double distance3 = keyboard.nextdouble();

    // determine total miles from total inches
    // Scale:  1 inch is 1/4 mile
    double totalMiles = totalInches * 1/4;        
    // add to get total inches on map
    distance1 + distance2 + distance2 + distance4 = totalInches;

    //round to one-tenth of a mile 
    int miles =(totalMiles + 0.05) * 10;

    //total miles
    int totalMiles = 10%

    // calculate kilometers
    totalKilos = totalMiles * miles * kilos;

    // round kilometers to tenths
    //int class kilos = totalKilos + {005 * 10)};
    //totalKilos = kilos / 100;

    // print results
    System.out.printn("Total inches:     " + "totalInches");
    Sytem.out.println ("Total miles:      " + milesTotal);
    System.out.prntln("Total kilometers: totalKilos");
    {
    }