Kotlin program to find area of Rectangle

Kotlin | Area of Rectangle: Here, we are going to implement a Kotlin program to find the area of Rectangle.
Submitted by IncludeHelp, on May 22, 2020

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

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






Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





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.