Kotlin program to find surface area of Sphere

Kotlin | Surface area of Sphere: Here, we are going to implement a Kotlin program to find the surface area of Sphere.
Submitted by IncludeHelp, on May 22, 2020

Formula to find surface area of Sphere: = 4*PI*r^2

Given the value of radius (r), we have to find the Surface area of Sphere.

Example:

    Input:
    radius = 12.6

    Output:
    surface area = 1995.036998735662

Program to find surface area of Sphere in Kotlin

package com.includehelp

import java.util.*
import kotlin.math.pow

//Main Function , Entry point of Program
fun main(args: Array<String>) {

    //Input Stream
    val scanner = Scanner(System.`in`)

    //Input Radius
    print("Enter Radius of Sphere : ")
    val radius = scanner.nextDouble()

    //surface Area of Sphere
    val sphereSurfaceArea = 4*Math.PI*radius.pow(2)

    //Print Surface Area
    println("Surface Area of Sphere on radius $radius is :$sphereSurfaceArea")
}

Output

Run 1:
Enter Radius of Sphere : 6
Surface Area of Sphere on radius 6.0 is :452.3893421169302
---
Run 2:
Enter Radius of Sphere : 12.6
Surface Area of Sphere on radius 12.6 is :1995.036998735662






Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.