ADVERTISEMENT
ADVERTISEMENT

Kotlin program to find area of a cylinder

Kotlin | Area of a cylinder: Here, we are going to implement a Kotlin program to find area of a cylinder.
Submitted by IncludeHelp, on May 08, 2020

A cylinder is a three-dimensional structure which has circular bases parallel to each other.

Formula to find area of a cylinder: 2*PI*(radius+height)

Give radius and height, we have to find area of a cylinder.

Example:

    Input:
    Radius = 5
    Height = 7

    Output:
    Surface Area of Cylinder is :75.39822368615503

Program to find area of a cylinder in Kotlin

package com.includehelp

import java.util.*

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

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

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

    //Input Height
    print("Enter Height of Cylinder : ")
    val height = scanner.nextDouble()

    //Cylinder Surface Area
    val areaCylinder = 2*Math.PI*(radius+height)

    //Print Area
    println("Surface Area of Cylinder is :$areaCylinder")
}

Output

Run 1:
Enter Radius of Cylinder : 5
Enter Height of Cylinder : 7
Surface Area of Cylinder is :75.39822368615503
---
Run 2:
Enter Radius of Cylinder : 29
Enter Height of Cylinder : 4
Surface Area of Cylinder is :207.34511513692635
ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

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.