为什么“ Keyboard.readDouble()”不起作用?

时间:2018-12-09 01:12:49

标签: java

我要做的就是读取用户输入为double类型的输入,然后将其转换为另一个数字。我还知道方程式还不完整,现在不担心它,只希望它运行即可。我不明白我做错了什么。

curl -X GET -H 'Authorization: Token token-string-here' website_address

2 个答案:

答案 0 :(得分:0)

这有效:

package euroshoe;

import java.util.Scanner;

public class EuroShoe {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.println("EUROPEAN SHOE SIZE");
        System.out.println("Enter the length of your foot in inches:");
        double footLength = input.nextDouble();
        double euroSize = (((footLength - 9) * 3 / 2) + 15);
        System.out.println("Your European shoe size is " + euroSize);
    }
}

答案 1 :(得分:0)

如果您正在学习教程,请检查提到的 进口 。但是要回答您的问题并使程序正常运行,这是一个答案。

import java.util.Scanner

public class EuroShoe {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        int i = 

        double footLength, euroSize;

        System.out.println("EUROPEAN SHOE SIZE");
        System.out.println("Enter the length of your foot in inches:");

        // The statement below calls the "scanner" object to get the user input of value "double"
        footLength = scanner.nextDouble();

        euroSize = (((footLength - 9) * 3 / 2) + 15);
        System.out.println("Your European shoe size is " + euroSize);
    }
}

请务必在上面放置此声明

import java.util.Scanner // imports the specific Scanner class under the 'util' namespace

或者您也可以使用它

import java.util.* // imports every class under the 'util' namespace

希望这可以帮助您解决问题并保持编码! :)