Q:

Kotlin program to find area of Equilateral Triangle

belongs to collection: Kotlin Basic Programs

0

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

All Answers

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

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

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 Parallelogram... >>
<< Kotlin program to find area of a cylinder...