Q:

Kotlin program to find area of a cube

0

A cube has 6 square faces, if edges length is side. Then the area of each square is side2, thus, the area of cube will be 6*sise2.

Given the value of side of the cube, we have to find its area.

Example:

    Input:
    side = 5

    Output:
    Area of cube = 150.0

All Answers

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

Program to find area of a cube 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 side
    print("Enter Side of Cube : ")
    val side = scanner.nextDouble()

    //Cube Surface Area
    val areaCube = 6*Math.pow(side, 2.toDouble())

    //Print Area
    println("Cube Surface Area on Side ($side) is :$areaCube")
}

Output

Run 1:
Enter Side of Cube : 5
Cube Surface Area on Side (5.0) is :150.0
---
Run 2:
Enter Side of Cube : 12
Cube Surface Area on Side (12.0) is :864.0

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

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now