Beginner Level

Implement the method calculateCircleArea that takes the radius of a circle as a float and returns its area.

Write a method to compute the area of a circle using the formula: Area = π × radius²
  • Use π = 3.14 for calculation.
  • The radius is provided as a float input.
  • The returned value should also be a float.

Example 1

Input
r (float) = 2
Returns (double) 12.56

Example 2

Input
r (float) = 3.5
Returns (double) 38.465

Example 3

Input
r (float) = 1
Returns (double) 3.14

To calculate the area of a circle:

  • Use the formula Area = 3.14 × radius × radius
  • Accept the radius as input
  • Return the area as a float value

Pseudocode:

Function calculateCircleArea(radius):
    return 3.14 * radius * radius
Ready to test your solutionRun Code checks your solution against the test cases.Shift + Enter to run

Notifications

Updates are enabled for this browser.

Receive new tutorials, articles and learning resources. You can turn updates off anytime.

Test browser code

Use this code in admin to send a test notification to this browser.