import { log } from "console"; import {square,PI,sqrt} from '../Local' var prompt = require('prompt-sync')() function __Area_of_Square(side:number) { return ((side ** 2)); } /** * Get function area of rectangle * * @param {number} l length * @param {number} b breadth */ function __Area_of_rectangle(l:number, b:number) { return (l * b); } function __Area_of_parallelogram(Base:number, height:number) { return (Base * height); } function __Area_of_triangle(Base:number, height:number) { return ((1 / 2) * Base * height) } function __Area_of_circle(radius:number) { return (3.14 * (radius ** 2)); } function __Area_of_rhombus(diagonal1:number, diagonal2:number) { return ((1 / 2) * (diagonal1 * diagonal2)); } function __Area_of_equilateral_triangle(side:number) { return ((Math.sqrt(3) / 4) * (side ** 2)); } function __AreaOf(shape: any):string{ var Shape = shape if(shape == 'square' ||shape == 'Square'){ log(`[Area of Square]`) const side = prompt('Side> ') return(`[[Area of square] : ${square(side)}]`) } else if(shape == 'triangle' || shape == 'Triangle'){ log('[Area of Triangle]') const Base = prompt('Base> ') const Height = prompt('Height> '); return(`[[Area of triangle] : ${(1/2) * Base * Height}]`) } else if(shape == 'rectangle' || shape == 'Rectangle' || shape == 'Parallelogram' || shape == 'parallelogram') { log(`[Area of ${Shape}]`) const length = prompt('Length/height> ') const breadth = prompt('Breadth/base> ') return(`[[Area of ${Shape}] : ${length*breadth}]`) } else if (shape == 'rhombus' || shape == 'Rhombus'){ log('[Area of Rhombus]') const D1 = prompt('Diagonal1> '),D2 = prompt('Diagonal2> ') return(`[[Area of Rhombus] : ${D1*D2}]`) } else if (shape == 'Circle' || shape == 'circle'){ log('[Area of Circle]') const radii = prompt('Radius> ') return(`[[Area of Circle] : ${PI * square(radii)}]`) } else if (shape == 'equilateral triangle' || shape=='Equilateral Triangle' || shape == 'equilateral Triangle' || shape == 'Equilateral triangle'){ log('[Area of Equilateral Triangle]') const side = prompt('Side> ') return(`[[Area of EQUI_Triangle] : ${(sqrt(3) / 4) * square(side)}]`) } else if (shape == 'oval' || shape == 'eclipse' || shape == 'Oval' || shape == 'Eclipse'){ log('[Area of Oval/Eclipse]') const r1 = prompt('Short Radius> ') const r2 = prompt('Long Radius> ') return(`[[Area of Oval / Eclipse] : ${PI * r1 * r2}]`) } else if (shape == 'pentagon' || shape == 'Pentagon'){ log(`[Area Of Regular Pentagon]`) const sid = prompt(`[Side]>> `) return(`[[Area Of Regular Pentagon] [Side = ${sid}] : ${(1/4) * Math.sqrt(5*(5+2*(Math.sqrt(5)))) * square(sid)}]`) } else if (shape == 'Hexagon' || shape == 'hexagon') { log(`[Area Of Hexagon]`) const side = prompt(`[Side]: `) return(`[[Area Of Hexagon] [Side = ${side}] ≈ ${Math.round(((3*Math.sqrt(3)) / 2) * square(side) *10000)/10000}]`) } else if(shape == 'heptagon' || shape == 'Heptagon') { log(`[Area Of Heptagon]`) const side = prompt(`[Side]: `) return(`[[Area of Heptagon] [Side = ${side}] ≈ ${square(side) * 3.635}]`) } else { return('[ERR 404!] --- Please provide a supported shape.') } } export { __Area_of_Square, __Area_of_circle, __Area_of_equilateral_triangle, __Area_of_parallelogram, __Area_of_rectangle, __Area_of_rhombus, __Area_of_triangle, __AreaOf }