diff --git a/lesson_06/expression/src/expression_calculator.ts b/lesson_06/expression/src/expression_calculator.ts index 13cb2ca05..5a78dafed 100644 --- a/lesson_06/expression/src/expression_calculator.ts +++ b/lesson_06/expression/src/expression_calculator.ts @@ -2,10 +2,35 @@ 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; + + // Caculate addition with an add function '(a + b)' + const originalSum = this.add(a, b); + // caculate multiplication '(add * c)' + const MultiplyMySum = this.multiply(originalSum, c); + //Specify the exponent 'd^e' + const myExponent = this.pow(d, e); + // caculate division 'multiply / exponent' + const DivideSum = this.divide(MultiplyMySum, myExponent); + // needs caculate it all... + const calculate = DivideSum; + return calculate; + + } + + add(x: number, y: number) { + return x + y; + } + + multiply(x: number, y: number) { + return x * y; + } + + divide(x: number, y: number) { + return x / y; } pow(base: number, exponent: number): number { return Math.pow(base, exponent); } } +