diff --git a/lesson_06/expression/src/expression_calculator.ts b/lesson_06/expression/src/expression_calculator.ts index 13cb2ca05..dc9221935 100644 --- a/lesson_06/expression/src/expression_calculator.ts +++ b/lesson_06/expression/src/expression_calculator.ts @@ -2,10 +2,36 @@ export class ExpressionCalculator { /** Returns the calculation of ((a + b) * c) / d^e */ calculate(a: number, b: number, c: number, d: number, e: number): number { // Implement your code here to return the correct value. - return 0; + const sum = this.add(a, b) + /* First step of PEMDAS in equation (Parenthesis)*/ + const product = this.multiply(sum, c) + /* Second step of PEMDAS in equation (Parenthesis)*/ + const power = Math.pow(d, e) + /* Third step of PEMDAS in equation (Exponent)*/ + const quotient = this.divide(product, power) + /* Fourth and final step of PEMDAS in equation [Multiplication/Division(left to right)]*/ + const result = quotient + /* Defines final result */ + return result; + /* prints final result*/ } + add(Augend: number, Addend: number,): number { + /* defines value of Augend and Addend; defines their return value*/ + return Augend + Addend; + /* defines the function 'add'*/ + } + multiply(Multiplicand: number, Multiplier: number): number { + /* defines value of Multiplicand and Multiplier; defines their return value*/ + return Multiplicand * Multiplier; + /* defines the function 'multiply'*/ + } + divide(Dividend: number, Divisor: number): number { + /* defines value of Dividend and Divisor; defines their return value*/ + return Dividend / Divisor; + /* defines the function 'divide'*/ + } pow(base: number, exponent: number): number { return Math.pow(base, exponent); } -} +} \ No newline at end of file diff --git a/lesson_06/expression/tsconfig.json b/lesson_06/expression/tsconfig.json index ced0628a9..96d7f3f58 100644 --- a/lesson_06/expression/tsconfig.json +++ b/lesson_06/expression/tsconfig.json @@ -111,4 +111,4 @@ "skipLibCheck": true /* Skip type checking all .d.ts files. */ }, "exclude": ["node_modules", "build"] -} +} \ No newline at end of file