Kotlin program to find area of Parallelogram

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

Problem statement

Given the value of base and height, we have to find the area of Parallelogram.

Kotlin - Find area of Parallelogram

Formula to find area of Parallelogram: area = base*height

Example:

Input:
base = 5
height = 8

Output:
area = 40.0

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

    //Input Height of Parallelogram
    print("Enter Parallelogram Height : ")
    val h = scanner.nextDouble()

    //Calculate Area of Parallelogram
    val areaParallelogram = b * h

    //Print Area
    println("Area of Parallelogram is :$areaParallelogram")
}

Output

Run 1:
Enter Parallelogram Base : 5
Enter Parallelogram Height : 8
Area of Parallelogram is :40.0
---
Run 2:
Enter Parallelogram Base : 5.7
Enter Parallelogram Height : 3
Area of Parallelogram is :17.1

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.