-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
  • 277,661
  • 50
  • 283
  • 320

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
  • 107,083
  • 22
  • 201
  • 376
Peter Lawrey
  • 513,304
  • 74
  • 731
  • 1,106
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
  • 277,661
  • 50
  • 283
  • 320