Circle Area
Programming Basics · Java
TASK
Problem
Read radius `r` as a decimal number and print the circle area using `Math.PI`.
EXAMPLE
Example
1
3.141592653589793
LIMITS
Constraints
0 ≤ r ≤ 10^6
LEARN
Theory for this problem
+
The core idea of **Circle Area** is to model the requested operation directly: Read radius `r` as a decimal number and print the circle area using `Math.PI`. The reference solution uses `Scanner` for input. Keep only the state needed for this result, choose numeric types that cover the stated bounds, and preserve the exact input/output contract. This makes the solution easier to verify on boundary cases and avoids unrelated work.
NEED HELP?
Hints
+
['Follow the statement for **Circle Area** literally and identify the smallest state needed to produce its output.', 'The reference solution relies on `Scanner` for input; test the smallest allowed input and one boundary case from the constraints.']
ANSWER
Solution
+
// CodeMaster — Circle Area
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double r = sc.nextDouble();
double area = Math.PI * r * r;
System.out.println(area);
}
}