Kotlin program to find area of Equilateral Triangle

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

Formula to find area of Equilateral Triangle: area = ( 1.73 × side × side)/4

Given the value of side, we have to find the area of Equilateral Triangle.

Example:

    Input:
    side = 7

    Output:
    area = 21.1925

Program to find area of Equilateral Triangle in Kotlin

package com.includehelp

import java.util.*
import kotlin.math.pow

//Main Function , Entry point of Program
fun main(args: Array<String>) {

    //Input Stream
    val scanner = Scanner(System.`in`)

    //Input Side of Equilateral Triangle
    print("Enter Side of Equilateral Triangle : ")
    val side = scanner.nextDouble()

    //Calculate Area of Equilateral Triangle
    val areaEquilateralTriangle = (1.73*side.pow(2))/4

    //Print Area
    println("Area of Equilateral Triangle on Side($side) is :$areaEquilateralTriangle")
}

Output

Run 1:
Enter Side of Equilateral Triangle : 7
Area of Equilateral Triangle on Side(7.0) is :21.1925
---
Run 2:
Enter Side of Equilateral Triangle : 21
Area of Equilateral Triangle on Side(21.0) is :190.7325






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.