Q:

Kotlin program to find area of a cylinder

belongs to collection: Kotlin Basic Programs

0

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

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Kotlin Basic Programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Kotlin program to find area of Equilateral Triangl... >>
<< Kotlin program to find surface area of a cuboid...