Skip to content

Instantly share code, notes, and snippets.

@sajjadyousefnia
Created June 6, 2018 09:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sajjadyousefnia/a534fbaa93b9e48b399e61a894a50de5 to your computer and use it in GitHub Desktop.
Save sajjadyousefnia/a534fbaa93b9e48b399e61a894a50de5 to your computer and use it in GitHub Desktop.
fun printCircumferenceAndArea(radius: Double): Unit {
fun calCircumference(radius: Double): Double = (2 * Math.PI) * radius
val circumference = "%.2f".format(calCircumference(radius))
fun calArea(radius: Double): Double = (Math.PI) * Math.pow(radius, 2.0)
val area = "%.2f".format(calArea(radius))
print("The circle circumference of $radius radius is $circumference and area is $area")
}
printCircumferenceAndArea(3.0) // The circle circumference of 3.0 radius is 18.85 and area is 28.27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment