Circumference area

Good night! I'm starting in Java, and I'm trying to complete the URI circumference area challenge. Is giving a lot of problem:

Exception in thread "main" java.useful.NoSuchElementException at java.useful.Scanner.Throwfor (Scanner.java:862) at java.useful.Scanner.next (Scanner.java:1485) at java.useful.Scanner.nextDouble (Scanner.java:2413) at Main.hand (hand.java: 9)

This is the code.

import java.util.Scanner;
public class Main
{
    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);

        double raio = scan.nextDouble();
        double n = 3.14159;
        double area = Math.pow(raio,2) * n;

        System.out.println("A=" +area);

    }
}

What am I doing wrong? I appreciate it now.

Author: G. Tavolaro, 2019-03-11

1 answers

By documentation :

public double nextDouble()
Scans the next token of the input as a double. This method will throw InputMismatchException if the next token cannot be translated into a valid double value. If the translation is successful, the scanner advances past the input that matched.
If the next token matches the Float regular expression defined above then the token is converted into a double value as if by removing all locale specific prefixes, group separators, and locale specific suffixes, then mapping non-ASCII digits into ASCII digits via Character.digit, prepending a negative sign (-) if the locale specific negative prefixes and suffixes were present, and passing the resulting string to Double.parseDouble. If the token matches the localized NaN or infinity strings, then either "Nan" or "Infinity" is passed to Double.parseDouble as appropriate.

Returns:
the double scanned from the input
Throws:
InputMismatchException - if the next token does not match the Float regular expression, or is out of range
NoSuchElementException - if the input is exhausted
IllegalStateException - if this scanner is closed

Ali says that to be thrown a NoSuchElementException, it is because the input "is over". Probably missing something to fill in as input.

 1
Author: Leonardo Alves Machado, 2019-03-11 22:18:16