Q:

Kotlin program to find area of Rectangle

belongs to collection: Kotlin Basic Programs

0

Formula to find area of Rectangle: area = length*width

Given the value of length and width, we have to find the area of Rectangle.

Example:

    Input:
    length = 2.6
    width = 3.2

    Output:
    area = 8.32

All Answers

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

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

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

    //Calculate Area of Rectangle
    val rectangleArea = length * width

    //Print Area
    println("Area of Rectangle is :$rectangleArea")
}

Output

Run 1:
Enter Rectangle Length : 2.6
Enter Rectangle Width : 3.2
Area of Rectangle is :8.32
---
Run 2:
Enter Rectangle Length : 6
Enter Rectangle Width : 8
Area of Rectangle is :48.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 Square... >>
<< Kotlin program to find area of circle...