My nextDouble(); scanner is giving me a “找不到符号” 错误

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

My nextDouble(); scanner is giving me a "cannott find symbol" error

问题

我正在为我的计算机科学课程做一个项目,但遇到了一个无法继续的问题。我试图做一个非常简单的用户输入问题,但一直出现错误。以下是我的代码和错误信息:

import java.util.*;

public class BeekeepingIncome{

   public static void main(String [] args)
   {
   double rawHoney;
   double honeyCombs; 
   double rent = 534.99;
   
   Scanner scanner = new Scanner(System.in);
   
   System.out.println("购买了多少磅的蜂蜜?");
   rawHoney = scanner.nextDouble();
   System.out.println("购买了多少磅的蜂巢?");
   
   // 其他代码...
   
   }
   
}

错误信息如下:

BeekeepingIncome.java:20: 错误: 无法找到符号
   rawHoney = scanner.nextDouble();
                   ^
  符号:   方法 nextDouble()
  位置: 类 BeekeepingIncome
1 个错误

有办法修复这个错误吗?
英文:

I am doing a project for my computer science class and I have run into an issue that wont let me proceed, I ma trying to do a really simple user input question but I keep getting an error. Here is my code and the error:

import java.util.*;

public class BeekeepingIncome{

   public static void main(String [] args)
   {
   double rawHoney;
   double honeyCombs; 
   double rent = 534.99;
   
   Scanner scanner = new Scanner(System.in);
   
   System.out.println("How much honey in pounds was purchased?");
   rawHoney = nextdouble();
   System.out.println("How many honey combs in pounds were purchased?");

   
   
   
   
   }
   
}

BeekeepingIncome.java:20: error: cannot find symbol
   rawHoney = nextDouble();
              ^
  symbol:   method nextDouble()
  location: class BeekeepingIncome
1 error

Any way I can fix this?

答案1

得分: 2

你需要使用你的 Scanner

rawHoney = scanner.nextDouble();

https://www.w3schools.com/java/java_user_input.asp

https://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html

英文:

You need to use your Scanner:

rawHoney = scanner.nextDouble();

https://www.w3schools.com/java/java_user_input.asp

https://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html

huangapple
  • 本文由 发表于 2020年8月5日 11:41:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/63258077.html
匿名

发表评论

匿名网友

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

确定