Q:

Kotlin program to find area of Square

0

Formula to find area of Square: area = side*side

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

Example:

    Input:
    side = 6

    Output:
    area = 36.0

All Answers

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

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

    //Calculate Area of square
    val squareArea = side*side;

    //Print Area
    println("Area of Square is : $squareArea")
}

Output

Run 1:
Enter Side of Square : 6
Area of Square is : 36.0
---
Run 2:
Enter Side of Square : 4.5
Area of Square is : 20.25

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