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

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

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

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

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

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.