Q:

Kotlin program to find area of Pentagon

0

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

All Answers

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

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

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

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now