ADVERTISEMENT
ADVERTISEMENT

Kotlin program to find surface area of a cuboid

Kotlin | Surface area of a cuboid: Here, we are implementing a Kotlin program to find surface area of a cuboid.
Submitted by IncludeHelp, on May 08, 2020

A cuboid is a three-dimensional figure which is bounded by 6 rectangular planes, they have different magnitude of length, width and height.

Formula to find surface area of a cuboid: 2( length*width + length*height + height*width)

Given length, width and height, we have to find surface area of a cuboid.

Example:

    Input:
    length = 3
    width  = 4
    height = 6

    Output:
    Surface Area of Cuboid is :108.0

Program to find surface area of a cuboid 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 Length of Cuboid
    print("Enter Cuboid Length : ")
    val length = scanner.nextDouble()

    //Input Width of Cuboid
    print("Enter Cuboid Width : ")
    val width = scanner.nextDouble()

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

    //Calculate surface area of cuboid
    val areaCuboid = 2*( length*width + length*height + height*width )

    //Print surface area of cuboid
    println("Surface Area of Cuboid is :$areaCuboid")
}

Output

Run 1:
Enter Cuboid Length : 3
Enter Cuboid Width : 4
Enter Cuboid Height : 6
Surface Area of Cuboid is :108.0
---
Run 2:
Enter Cuboid Length : 5
Enter Cuboid Width : 6
Enter Cuboid Height : 2
Surface Area of Cuboid is :104.0
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.