Kotlin program to find area of Pentagon

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

Problem statement

Given the value of Side and Apothem, we have to find the area of Pentagon.

Example:

Input:
side= 5
apothem = 6

Output:
area = 75.0

Kotlin - Find area of Pentagon

Formula to find area of Pentagon: = (5/2)sa, where

  • s - Side of Pentagon
  • a - Apothem of Pentagon

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

    //Input Apothem
    print("Enter Apothem of Pentagon : ")
    val a = scanner.nextDouble()

    //Area of Pentagon
    val areaPentagon = (5.0/2.0)*s*a

    //Print Area
    println("Pentagon Area is :$areaPentagon")
}

Output

Run 1:
Run 1:
Enter Side of Pentagon : 5
Enter Apothem of Pentagon : 6
Pentagon Area is :75.0
---
Run 2:
Enter Side of Pentagon : 8
Enter Apothem of Pentagon : 6
Pentagon Area is :120.0

Comments and Discussions!

Load comments ↻





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