英文:
The method is readDouble is undefined for the type
问题
import java.util.Scanner;
public class Pizza {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("你想要的比萨直径是多少?");
double pizzadiameter = readDouble("输入比萨直径:");
System.out.println("比萨的直径将是 " + pizzadiameter + "。");
}
}
英文:
import java.util.Scanner;
public class Pizza {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("what is the diameter of the pizza that you want?");
double pizzadiameter = readDouble("Enter pizza diameter: ");
System.out.println("The diameter of the pizza will be " + pizzadiameter + ".");
}
}
My problem is that double pizzadiameter = readDouble("Enter pizza diameter: ");
(line 6) is giving me an error saying the method is undefined.
答案1
得分: 0
你需要使用 input.nextDouble
来获取输入:
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("你想要的比萨直径是多少?");
double pizzadiameter = input.nextDouble();
System.out.println("比萨的直径将会是 " + pizzadiameter + "。");
}
英文:
you need to get the input using input.nextDouble
public static void main (String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("what is the diameter of the pizza that you want?");
double pizzadiameter = input.nextDouble();
System.out.println("The diameter of the pizza will be " + pizzadiameter + ".");
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论