-2
public static void main(String[] args) throws IOException {
    BufferedReader read = new BufferedReader(new Input StreamReader(System.in));
    double r, pi=3.14159;
    System.out.println("Please enter radius of sphere:`enter code here` ");
    r = Integer.parseInt(read.readLine());
    double area=(4/3.0)*pi*(r*r*r);
    System.out.println("Area of sphere is : "+area);
}
Mureinik
  • 297,002
  • 52
  • 306
  • 350

2 Answers2

0

It's O(1) as this will always take the same amount of time.

If your input is insanely long, its complexity is O(n) where n is the number of characters.

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
0

The execution time is not affected by the actual input or the size of the data. Therefore, this snippet has an O(1) complexity.

Mureinik
  • 297,002
  • 52
  • 306
  • 350