Q:

Kotlin program to find surface area of a cuboid

belongs to collection: Kotlin Basic Programs

0

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

All Answers

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

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

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 a cylinder... >>
<< Kotlin program to find area of a cube...