我正在为我的计算机科学课做一个项目,遇到了一个让我无法继续进行的问题,我试图做一个非常简单的用户输入问题,但我一直遇到错误。这是我的代码和错误:
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
有什么办法可以解决这个问题?
答案 0 :(得分: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