Q:

Kotlin program to find area of Parallelogram

belongs to collection: Kotlin Basic Programs

0

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

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

Example:

    Input:
    base = 5
    height = 8

    Output:
    area = 40.0

All Answers

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

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

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 Pentagon... >>
<< Kotlin program to find area of Equilateral Triangl...